
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2019 06:51 AM
I am building an integration between instance1 and instance2. When instance2 posts to the web service on instance1, the incident gets created correctly but I get no response body so I'm unable to pull the remote number out and set it on the initiating incident.
When I use REST API Explorer on instance1 and post to the same web service, I get the appropriate response body.
Here is my code:
var request = new sn_ws.RESTMessageV2("ABC Outbound Incident","create_incident");
request.setStringParameterNoEscape("summary",current.short_description);
request.setStringParameterNoEscape("description",jsonEncode(description + ''));
request.setStringParameterNoEscape("number",current.number);
request.setStringParameterNoEscape("company","XYZ");
request.setStringParameterNoEscape("caller","XYZHelp Desk");
request.setStringParameterNoEscape("reported_by","XYZ Help Desk");
request.setStringParameterNoEscape("urgency",urgency);
request.setStringParameterNoEscape("impact",impact);
request.setStringParameterNoEscape("group","Service Desk");
request.setStringParameterNoEscape("sysID",current.sys_id);
request.setStringParameterNoEscape("state","Queued");
request.setStringParameterNoEscape("substate","New");
request.setStringParameterNoEscape("comments",jsonEncode(comments + ''));
var response = request.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.addInfoMessage('httpStatus: ' + httpStatus);
gs.addInfoMessage('responseBody: ' + responseBody);
What is going on?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2019 06:17 AM
For anyone who stumbles on this post in the future, I fixed this by giving the user on instance1, whose credentials instance 2 was using to send data to instance1, the import_transformer role to get a response back.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2019 07:32 AM
What is "ABC Outbound Incident" outbound rest message?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2019 06:41 AM
Yes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2019 06:48 AM
Have you tried JSON parse instead of JSON encode??
https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=r_JSON-parse_S
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2019 08:09 AM
My issue isn't with sending the request, my issue is getting the expected response body. All I'm doing here is calling this script:
function jsonEncode(str)
{
str = new JSON().encode(str);
return str.substring(1,str.length - 1);
}
If I don't do that, the target instance will not accept my request.