Ad Widget

Collapse

ConnectWise Manage Integration api help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BingoThePyro
    Junior Member
    • Sep 2018
    • 7

    #1

    ConnectWise Manage Integration api help

    Hi, we are trying to create tickets in ConnectWise manage usnig the new Media Type Webhook feature. I have a successful get request (based on looking though other integrations and trying to minimise the code down) but cannot get a successful post.

    Here is my code:
    Code:
    try {
    Zabbix.log(4, '[ CWMTest webhook ] Started with params: ' + value);
    
    var result = {
    'tags': {
    'endpoint': 'cwm'
    }
    },
    params = JSON.parse(value),
    req = new HttpRequest(),
    //fields = {},
    resp;
    
    if (params.HTTPProxy) {
    req.setProxy(params.HTTPProxy);
    }
    
    req.addHeader('Content-Type: application/json');
    req.addHeader('Authorization: Basic ' + params.authentication);
    req.addHeader('clientId: ' + params.clientid);
    
    var data = {
    summary: 'test',
    recordType: 'ServiceTicket',
    initialDescription: 'test description',
    board: {
    name: 'IT RMM'
    },
    };
    JSON.stringify(data);
    
    resp = req.post(params.url, data);
    resp = JSON.parse(resp);
    Zabbix.log(4,(resp));
    result.tags.issue_id = resp.id;
    result.tags.issue_key = resp.key;
    
    return JSON.stringify(resp);
    }
    catch (error) {
    Zabbix.log(3, '[ CWM test webhook ] issue creation failed : ' + error + resp);
    throw 'Failed with error: ' + error;
    }
    and this is the error returned when testing the media type:
    "code": "ConnectWiseApi",
    "message": "Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'ConnectWise.Apis.v3_0.v2015_3.Service.Ticket.Tick et' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.\r\nPath '', line 1, position 1."

    So the message is fairly obvious but I cannot figure out how to get this right. I've tried 'one line-ing' the data and formatting as described above, but that made no difference.
    Also trying to google for new httprequest() is not that helpful; most results are for xmlhttpresquest or fetch neither of which appeared to work for the media type.

    Is someone help me out with this pleeeeease?

  • BingoThePyro
    Junior Member
    • Sep 2018
    • 7

    #2
    This is what I needed:
    Code:
    data = JSON.stringify(data);

    Comment

    • Brian.Nguyen
      Junior Member
      • Nov 2021
      • 1

      #3
      Hi BingoThePyro,

      I'm new to Zabbix and currently I want to set up an integration between Zabbix and Connectwise manage. Do you have any documentation for this? Or anything that can help me complete this integration. Please help me.

      Thank you so much,
      Brian

      Comment

      • ojackson
        Junior Member
        • Nov 2023
        • 2

        #4
        6000 years later, but I wrote and documented this one:


        Comment

        Working...