- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2018 06:09 PM
Hi, everyone. I'm hoping y'all can help me. I'm calling an outbound REST message through a business rule to another ServiceNow instance (a vendor's instance) using the Table API. That part is working fine. I've set the application type as JSON, and I've confirmed it's set correctly by examining the header's Content-Type. I'm getting results back, but when I try to parse them using the JSON parser, the whole thing stops working (even the REST call itself). I created a fix script to try to figure it out, and here's what I've got (I'm manually setting the response here, but it's a trimmed down version of what I'm getting back from the REST message):
var response = '{"result":{"number":"CS0005834","state":"1","case":"CS0005834","impact":"2","active":"true"}}';
var parser = new JSONParser();
var parsedResponse = parser.parse(response);
gs.print('response: ' + response);
gs.print('parsedResponse: ' + parsedResponse.result);
gs.print('parsedResponse.number: ' + parsedResponse.result[0].number);
I just need the number -- but I it's coming back as undefined. What am I doing wrong? And, any idea why adding the parsing code would make the REST call fail?
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2018 06:41 PM
Here it is for the sample :
var response = '{"result":{"number":"CS0005834","state":"1","case":"CS0005834","impact":"2","active":"true"}}';
var parsedResponse = JSON.parse(response);
gs.print('response: ' + response);
gs.print('parsedResponse: ' + parsedResponse.result);
gs.print('parsedResponse.number: ' + parsedResponse.result.number);
You can also utilize for the actual response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2018 11:49 AM
Thanks, y'all -- much appreciated. I made the change, and the BR now works like a dream.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2019 10:33 AM
Any chance you can provide the actual Fix Script you implemented? Would be greatly appreciated!