"Exception while reading request","detail":"The payload is not valid JSON."},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2021 04:16 AM
I am working on Post REST Integration for Incident table and written below Business Rule but while i am checking the logs its showing error.
Please help to fix the error.
***********************************************************************************************************************************
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://dev64283.service-now.com/api/now/table/incident');
request.setHttpMethod('POST');
//Eg. UserName="admin", Password="admin" for this code sample.
var user = 'Integration_user';
var password = 'test@1234';
request.setBasicAuth(user,password);
request.setRequestHeader("Accept","application/json");
request.setRequestHeader('Content-Type','application/json');
request.setRequestBody("{\"short_description\":\"" + current.short_description + "\"\"caller_id\":\"" + current.caller_id + "\"\"priority\":\""+current.priority + "\"\"category\":\""+ current.category
+"\" }");
var response = request.execute();
current.work_notes = response.getBody();
current.update();
//gs.log(response.getBody());
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2021 11:12 PM
> i am checking the logs its showing error.
The first question that comes up is what is the error message saying? Would help if the error message is posted.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2021 11:27 PM
Try with following statement:
request.setRequestBody("{\"short_description\":\"" + current.short_description + "\",\"caller_id\":\"" + current.caller_id + "\",\"priority\":\"" + current.priority + "\",\"category\":\"" + current.category + "\"}");
If error persists, try changing current.short_description, current.caller_id, current.priority, and current.category with a static value.