I-doit integration

  • Used Zammad version: 2.8
  • Used Zammad installation source: debian package
  • Operating system: debian 9
  • Browser + version: any

Expected behavior:

  • i-doit integration should work perfectly
  • i-doit objects should be accessible

Actual behavior:

Steps to reproduce the behavior:

  • save i-doit integration settings
  • try to fetch i-doit objects

error messages in i-doit log:
[2018-12-17 18:38:15 704429] INFO: -------------------------------------------------------------
[2018-12-17 18:38:15 704858] DEBUG: i-doit JSON-RPC API v1.10 - i-doit 1.12 PRO
[2018-12-17 18:38:15 705173] DEBUG: Provided raw request:
{
“method”: “cmdb.object_types”,
“params”: {
“apikey”: “myapikey”
},
“version”: “2.0”
}
[2018-12-17 18:38:15 705311] INFO: 1 request(s) to proceed.
[2018-12-17 18:38:15 705465] INFO: Processing request 1/1:
{
“method”: “cmdb.object_types”,
“params”: {
“apikey”: “myapikey”
},
“version”: “2.0”
}
[2018-12-17 18:38:15 705586] DEBUG:
{
“method”: “cmdb.object_types”,
“params”: {
“apikey”: “myapikey”
},
“version”: “2.0”
}
[2018-12-17 18:38:15 705722] WARNING: Request is an notification - aborting.
[2018-12-17 18:38:15 706079] INFO: [METRICS] Request time: 1 request(s) took 0.00056791305541992s.
[2018-12-17 18:38:15 706198] INFO: [METRICS] Requests per second: 1760.8329135181s.
[2018-12-17 18:38:15 706309] INFO: [METRICS] Indexing time: 0s.
[2018-12-17 18:38:15 706436] INFO: [METRICS] Total time: 0.00056791305541992s.

production.log outputs:
I, [2018-12-17T18:51:41.338299 #15919-47199067156320] INFO – : Running job thread for ‘Execute jobs’ (Job.run) status is: sleep
I, [2018-12-17T18:51:53.658235 #15914-70226782645100] INFO – : Started POST “/api/v1/integration/idoit/verify” for 127.0.0.1 at 2018-12-17 18:51:53 +0100
I, [2018-12-17T18:51:53.662902 #15914-70226782645100] INFO – : Processing by Integration::IdoitController#verify as JSON
I, [2018-12-17T18:51:53.662968 #15914-70226782645100] INFO – : Parameters: {“method”=>“cmdb.object_types”, “api_token”=>“myapitoken”, “endpoint”=>“http://idoithostname”, “client_id”=>""}
I, [2018-12-17T18:51:54.244719 #15914-70226743877220] INFO – : Started GET “/api/v1/http_logs/idoit?limit=50&=1545068948713" for 127.0.0.1 at 2018-12-17 18:51:54 +0100
I, [2018-12-17T18:51:54.248869 #15914-70226743877220] INFO – : Processing by HttpLogsController#index as JSON
I, [2018-12-17T18:51:54.248941 #15914-70226743877220] INFO – : Parameters: {“limit”=>“50”, "
”=>“1545068948713”, “facility”=>“idoit”}
I, [2018-12-17T18:51:54.398732 #15914-70226782645580] INFO – : Started PUT “/api/v1/taskbar/37” for 127.0.0.1 at 2018-12-17 18:51:54 +0100
I, [2018-12-17T18:51:54.401467 #15914-70226743877220] INFO – : Completed 200 OK in 152ms (Views: 142.0ms | ActiveRecord: 4.9ms)
I, [2018-12-17T18:51:54.404938 #15914-70226782645580] INFO – : Processing by TaskbarController#update as JSON
I, [2018-12-17T18:51:54.406660 #15914-70226782645580] INFO – : Parameters: {“key”=>“Ticket-6”, “client_id”=>“123”, “callback”=>“TicketZoom”, “state”=>{“ticket”=>{}, “article”=>{“form_id”=>“069024360”}}, “params”=>{“ticket_id”=>6, “overview_id”=>12, “shown”=>true}, “prio”=>2, “notify”=>false, “active”=>false, “attachments”=>[], “updated_at”=>“2018-12-17T17:49:38.262Z”, “id”=>“37”}
I, [2018-12-17T18:51:54.447958 #15914-70226782645580] INFO – : Completed 200 OK in 41ms (Views: 0.5ms | ActiveRecord: 5.2ms)
E, [2018-12-17T18:51:58.707299 #15914-70226782645100] ERROR – : Can’t fetch objects from http://idoithostname/src/jsonrpc.php: #<JSON::ParserError: 765: unexpected token at ‘’> (RuntimeError)
/opt/zammad/lib/idoit.rb:124:in _query' /opt/zammad/lib/idoit.rb:25:inverify’

Settings in zammad are quite simple:
API Token is (not really) myapitoken
Endpoint is http://idoithostname

have tried it with http://idoithostname/src/jsonrpc.php as well, same error

Settings in i-doit as well:
API-Key is (not really) myapitoken
“Activate JSON-RPC API” is active
“Enforce authentication by username and password” is inactive

what am I doing wrong?

Thanks

Babak

1 Like

I have the same Problem after Update I-Doit to Version 1.12
With I-Doit Version 1.11 there are no Problem.

I currently have no instance of i-doit for playing so I can’t help here, maybe @svnr-dvnkln can? :smiley:

1 Like

What version of the api add-on are you using?

They released 1.10 two days ago which is needed for >= 1.12.

P.S.: I’m still on 1.11.2, need to confirm this on 1.12. I’m probably gonna try this tomorrow.

cheers

2 Likes

I use the api add-on 1.10

Thank you

Phew, well… i did some digging but i didn’t get the result i expected.

Here’s what i know until now:

When you first try to browse i-doit objects zammad seems to send the following request to get all object types:
{"method":"cmdb.object_types","params":{"apikey":"$insertapikeyhere"},"version":"2.0"}

This request works perfectly fine with i-doit 1.11.2 and i-doit API 1.9.1
As soon as you upgrade to i-doit 1.12 and i-doit API 1.10 you’re pretty much screwed and receive the following message:

Can’t fetch objects from https://$insertfancyidoitserverhere/src/jsonrpc.php: #

If you investigate the log in zammad’s WebUI (System - Integration - i-doit) the response row is left blank. Usually there should be tons of informations (all object types ofc).

So my first guess was that they (synetics) changed something in the response output format and zammad isn’t able to read it anymore.

Therefore i fired up some powershell script and ran the same request zammad seems to post against my 1.11.2 installation and my 1.12 installation to compare the responses. Here are some examples:

1.11.2

id               : 1
title            : System service
container        : 0
const            : C__OBJTYPE__SERVICE
color            : 987384
image            : https://$insertfancyidoitserverhere/images/objecttypes/service.jpg
icon             : images/icons/silk/application_osx_terminal.png
cats             : 4
tree_group       : 1
status           : 2
type_group       : 1
type_group_title : Software

1.12

id               : 1
title            : System service
container        : 0
const            : C__OBJTYPE__SERVICE
color            : 987384
image            : https://$insertfancyidoitserverhere/images/objecttypes/service.jpg
icon             : images/icons/silk/application_osx_terminal.png
cats             : 4
tree_group       : 1
status           : 2
type_group       : 1
type_group_title : Software

Pretty much the same for me… need to look further into this when i got the time to.

cheers

1 Like

Aaaaah @MrGeneration @thorsteneckel we got different jsonrpc.php files over here… is this of interest for you guys?

Edit on the 1.11.2 one - i failed the copy paste part (shame on me).

jsonrpc.php (i-doit 1.11.2)

<?php

/**
 * JsonRPC
 *
 * @package    i-doit
 * @subpackage API
 * @author     S. Kekec <***@i-doit.de>
 * @version    1.10
 * @copyright  synetics GmbH
 * @license    http://www.i-doit.com/license
 */

// Check if api is present
if (file_exists(__DIR__ . '/classes/modules/api/jsonrpc.php')) {
    // Calculate idoit root directory
    $idoitRootDirectory = dirname(__DIR__);

    // Include api entry point file
    include_once __DIR__ . '/classes/modules/api/jsonrpc.php';
} else if (file_exists(__DIR__ . '/jsonrpc_legacy.php')) {
    // Calculate idoit root directory
    $idoitRootDirectory = dirname(__DIR__);

    // Include legacy api entry point file
    include_once __DIR__ . '/jsonrpc_legacy.php';
}

Maybe someone with a “super clean” 1.11.2 can doublecheck his jsonrpc.php?
I’m pretty sure i corrupted my file with some api beta geek stuff (i honestly don’t know why it says it’s api version 1.10 - should’ve been 1.9.1).

jsonrpc.php (i-doit 1.12)

<?php

/**
 * JsonRPC
 *
 * @package    i-doit
 * @subpackage API
 * @author     S. Kekec <***@i-doit.de>
 * @version    1.10
 * @copyright  synetics GmbH
 * @license    http://www.i-doit.com/license
 */

// Set error reporting.
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING);

include_once __DIR__ . '/../vendor/autoload.php';

use idoit\Context\Context;

Context::instance()->setOrigin(Context::ORIGIN_API);

// Check if api is present
if (file_exists(__DIR__ . '/classes/modules/api/jsonrpc.php')) {
    // Calculate idoit root directory
    $idoitRootDirectory = dirname(__DIR__);

    // Include api entry point file
    include_once __DIR__ . '/classes/modules/api/jsonrpc.php';
} else if (file_exists(__DIR__ . '/jsonrpc_legacy.php')) {
    // Calculate idoit root directory
    $idoitRootDirectory = dirname(__DIR__);

    // Include legacy api entry point file
    include_once __DIR__ . '/jsonrpc_legacy.php';
} else {
    /**
     * Inform caller that api is not present
     */
    echo json_encode([
        'id'      => 0,
        'jsonrpc' => '2.0',
        'error'   => [
            'code'    => -1,
            'message' => 'Api Module is not available.',
            'data'    => null
        ]
    ]);

    die;
}

cheers

2 Likes

The Content of src/jsonrpc.php from i-doit 1.11.2:

<?php

/**
 * JsonRPC
 *
 * @package    i-doit
 * @subpackage API
 * @author     Selcuk Kekec <skekec@i-doit.de>
 * @version    1.10
 * @copyright  synetics GmbH
 * @license    http://www.i-doit.com/license
 */

// Check if api is present
if (file_exists(__DIR__ . '/classes/modules/api/jsonrpc.php')) {
    // Calculate idoit root directory
    $idoitRootDirectory = dirname(__DIR__);

    // Include api entry point file
    include_once __DIR__ . '/classes/modules/api/jsonrpc.php';
} else if (file_exists(__DIR__ . '/jsonrpc_legacy.php')) {
    // Calculate idoit root directory
    $idoitRootDirectory = dirname(__DIR__);

    // Include legacy api entry point file
    include_once __DIR__ . '/jsonrpc_legacy.php';
}

The script src/classes/modules/api/jsonrpc.php doesn’t exist in i-doit 1.11.2, so that src/jsonrpc_legacy.php will be used. After upgrading to 1.12, src/classes/modules/api/jsonrpc.php exists.

I have to do some further investigations on this issue and post an update as soon ASAP

ciao
chris

3 Likes

I’ll take a look and install a i-doit playground asap and get back to you guys.

Thank you very much for the detailed answer so far

2 Likes

Can someone, from Zammad, Contact me?
Iam from i-doit Support.

3 Likes

We could verify this being a bug, the issue can be found here:

1 Like

Hi @mhuhn - thanks for reaching out! Do I understand the API documentation correctly that this ID was required all along but wasn’t used/checked that strict before? Since this is/was the JSON-RPC standard adding the ID won’t break the integration for i-doit installations with version < 1.12, right?

1 Like

This will not affect any installation < 1.12. Even if API 1.10 is installed there.

2 Likes

You are are amazing - every single one of you. Thanks a ton for this outstanding community teamwork! As you might already noticed this is fixed in the develop and stable branches - releases will be ready in about 30 minutes from now.

Make sure to contact us for the giveaway - you’d all deserve it :muscle:

3 Likes

Guys, this is the definition of greatness!

Thanks a big bunch!

Have nice holidays, you all deserve it!

Babak

2 Likes

The issue has been fixed.
This should be in the repos already, feel free to update :slight_smile:

2 Likes

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.