3 Replies · Latest reply on Apr 21, 2017 7:36 AM by Chris Martin

    How can api payload as {data:{ ?!

      This this is my, doctored, outbound BR script to post an incident ticket to a 3rd party vendor:

       

      var request = new sn_ws.RESTMessageV2();

      request.setEndpoint('https://company.com/endpointRestService/createOrUpdateTicket');

      request.setHttpMethod('POST');

      request.setRequestHeader('authCode','code here');

      request.setRequestHeader('Accept','application/x-www-form-urlencoded');

      request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

      request.setRequestBody('{data: {"message":"SNow call to api","secondaryContactEmail":"store.store@company.com","reason":"testing purpose.","secondaryContactName":"name here test","priority":"medium","secondaryContactNumber":"987-654-9999","primaryContactEmail":"mgr.store@company.com","primaryContactNumber":"1234","primaryContactName":"Dave  test","custom1":"INC00123453","custom2":"Store Number 123"}}');

      var response = request.execute();

      gs.log('API Status v2: ' +response.getStatusCode());

      gs.log('API Response v2: ' +response.getBody());

       

      Now the company I need to send the data to have built their own ITSM tool and they need the data sent as 'x-www-form-urlencoded' and they must have the payload sent with {data:{ before the fieldnames:values.

       

      I can't seem to get past the response message of '{"message":"data is not valid."}' / status: 400

       

      Can anyone help?

      Dave