Outbound REST Call From a SN Instance to a SN Instance Returns HTTP-400 and Error: Cannot decode: java.io.StringReader@13182e5","message":"Exception while reading requestIssue An outbound POST is made from one ServiceNow instance to another ServiceNow instance to create an incident using the REST Table API (/api/now/table/incident). The description field of the incident from the sending instance is copied and sent as the description to the receiving instance. The outbound REST message is defined. The request is sent using this background script, this is where the description field is set, the error is shown as well: var request = new sn_ws.RESTMessageV2('slu1', 'post');var gr = new GlideRecord('incident');gr.addQuery("sys_id","=","f73ecdd7137110507781b7566144b001");gr.query();while(gr.next()){request.setStringParameterNoEscape('description',gr.description);} var response = request.execute();gs.print(response.getBody()); Output: REST Msg Outbound - RESTMessageClient : Constructing REST Message/Method: slu1/postREST Msg Outbound - RESTMessageClient : Executing synchronous requestREST Msg Outbound - RESTMessageClient : Executing: Outbound REST Message/Method: slu1/postHTTP Request: POST https://<instance>.service-now.com/api/now/table/incident?sysparm_display_value=true Accept Value: application/json Content-Type: application/jsonAuthentication type: basicAuthentication profile: Profile name: ********** Username: ********** Password: ********Mutual Auth: falseECC Queue: falseRequest Content: Length: 2694 Content First 100 Bytes: {"description":"desc"... REST Msg Outbound - RESTMessageClient : Response: Outbound REST ResponseHTTP Status: 400 Bad RequestX-Is-Logged-In: trueX-Transaction-ID: 42c287601b42Pragma: no-store,no-cacheCache-control: no-cache,no-store,must-revalidate,max-age=-1Expires: 0Content-Type: application/json;charset=UTF-8Transfer-Encoding: chunkedDate: Mon, 13 Jul 2020 20:43:09 GMTX-Cnection: closeServer: ServiceNowSet-Cookie: JSESSIONID=abc; Path=/; HttpOnly; SameSite=None; SecureSet-Cookie: glide_user=; Max-Age=0; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly; SameSite=None; SecureSet-Cookie: glide_user_session=; Max-Age=0; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly; SameSite=None; SecureSet-Cookie: glide_user_route=glide.49b1024e8d51746c651cf7a0598333e0; Max-Age=2147483647; Expires=Sat, 31-Jul-2088 23:57:16 GMT; Path=/; HttpOnly; SameSite=None; SecureSet-Cookie: glide_session_store=0EC287601B4210906BD164A6BC4BCBEF; Max-Age=1800; Expires=Mon, 13-Jul-2020 21:13:09 GMT; Path=/; HttpOnly; SameSite=None; SecureSet-Cookie: BIGipServerpool_inst=176510986.56638.0000; path=/; Httponly; Secure; SameSite=None; SecureStrict-Transport-Security: max-age=63072000; includeSubDomainsError: Error Code: 1 Error Message: Method failed: (/api/now/table/incident) with code: 400 *** Script: {"error":{"detail":"Cannot decode: java.io.StringReader@e5a6cc","message":"Exception while reading request"},"status":"failure"} ReleaseApplies to any releaseCauseThere are invalid characters in the incident's description field (this could be any field or fields, description is just used as an example) that cannot be parsed by the receiving instance. Regex expressions must be used to make the JSON valid and parsable by the receiving instance. To find the cause turn on glide.rest.debug = true system property on the receiving instance. For this example this is the important error from the log at the receiving instance: Caused by: org.codehaus.jackson.JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value CTRL-CHAR code 10 is line feed character which is \r - this needs to be sent as escaped to be valid - that is as \\r After this is corrected the error changes to show this: Caused by: org.codehaus.jackson.JsonParseException: Illegal unquoted character ((CTRL-CHAR, code 9)): has to be escaped using backslash to be included in string value CTRL-CHAR code 9 is tab character which is \t - this needs to be sent as escaped to be valid - that is as \\t There may be many other errors or errors with different values of "code x", the code is from the standard ascii character set as a decimal value, see: http://www.asciitable.com/ResolutionTo fix the first error (code 10) you can send the request using regex like this to escape the \r with \\r : var request = new sn_ws.RESTMessageV2('slu1', 'post'); var gr = new GlideRecord('incident');gr.addQuery("sys_id","=","f73ecdd7137110507781b7566144b001");gr.query();while(gr.next()){request.setStringParameterNoEscape('description', gr.description.replace(/(\r\n|\n|\r)/gm,"\\r"));} var response = request.execute();gs.print(response.getBody()); After executing the above the "code 9" error will be seen in the receiving instance's node log. To fix the second error (code 9) you can change the above request further using regex to escape the \t with \\t - both fixes for \r and \t are here: var request = new sn_ws.RESTMessageV2('slu1', 'post');var gr = new GlideRecord('incident');gr.addQuery("sys_id","=","f73ecdd7137110507781b7566144b001");gr.query();while(gr.next()){var temp_desc = gr.description.replace(/(\r\n|\n|\r)/gm,"\\r"));request.setStringParameterNoEscape('description', temp_desc.replace(/(\t)/gm,"\\t"));}var response = request.execute();gs.print(response.getBody()); This should return a HTTP-201 and create the incident on the far-end instance. When comparing the format of the original incident.description with the newly created incident.description, they should be formatted the same.Related LinksSee these for more information: https://stackoverflow.com/questions/49209362/what-is-the-meaning-of-s-s-gm-in-javascript/49209436 https://community.servicenow.com/community?id=community_question&sys_id=3bc1610cdbcd13c0b61ff3231f96191d