"Exception while reading request","detail":"The payload is not valid JSON."},

Abhishek66
Tera Contributor

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());

6 REPLIES 6

Hitoshi Ozawa
Giga Sage
Giga Sage

> 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.

Hitoshi Ozawa
Giga Sage
Giga Sage

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.