- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2020 01:35 PM
Hi, i am doing a rest integration with two servicenow instances for incident module and i am getting below error for response when REST service is initiating the call.
{"error":{"message":"Exception while reading request","detail":"Cannot decode: java.io.StringReader@2cc3d83"},"status":"failure"}
i have created outbound REST with HTTP headers "accept = application/JSON" and "content-Type = application/JSON"
and in the script i am passing the description like below (after trial and error i find incident description is creating this issue if we have given multiple lines of text, but its not an issue if i have given only a single line of text)
r.setStringParameterNoEscape('description',current.description);
and in the POST function i am passing content like below
{
"short_description":"${short_description}",
"description":"${description}",
}
i searched community and try to understand the issue but still not able to find accurate help to fix this error. Please help me if anyone has encountered this issue.
Business rule script:
(function executeRule(current, previous /*null when async*/) {
try {
var r = new sn_ws.RESTMessageV2(' REST Incident', 'post');
r.setStringParameterNoEscape('short_description', current.short_description);
r.setStringParameterNoEscape('description',current.description);
r.setStringParameterNoEscape('callerID',current.sys_id);
var response = r.execute();
var responseBody = response.getBody();
gs.log("rbody is "+responseBody);
var json = responseBody;
var obj = JSON.parse(json);
var foundsysID = obj.result.sys_id;
current.correlation_id = foundsysID;
current.update();
var httpStatus = response.getStatusCode();
}
catch(ex) {
var message = ex.message;
}
})(current, previous);
thanks,
sry
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2020 12:12 AM
Hi,
This are the few solution:
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2020 01:44 PM
HI,
Try this:
r.setStringParameterNoEscape('short_description', current.getValue('short_description));
r.setStringParameterNoEscape('description',current.getValue('description));
r.setStringParameterNoEscape('callerID',current.getValue('sys_id')); I dont see this in content
{
"short_description":"${short_description}",
"description":"${description}",
}
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2020 02:04 PM
Hi Ashutosh, thank you for prompt reply.
i tried current.getValue('field_name') for every field but still same error in the log.
yes the content was missing caller, i have corrected it.
{
"short_description":"${short_description}",
"description":"${description}",
"correlation_id":"${callerID}",
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2020 12:12 AM
Hi,
This are the few solution:
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2020 12:07 PM
Hi Ashutosh, thank you very much. below article helped for my issue.
https://community.servicenow.com/community?id=community_question&sys_id=160ad2c6db93e700107d5583ca9619c4&anchor=answer_bc15ab06dbd32f409a64e15b8a9619cd&view_source=searchResult
thanks,
sry