REST API Integration not working while using the PUT method to update incident on another SNOW instance

suhan07
Kilo Contributor

Hi, 

I am new to REST API Integration, still exploring the ServiceNow learning curve. I am trying to implement an eBonding integration between two SN instances - SN1 (source) and SN2 (target). 

I am able to successfully create the incident. However, when I am trying to update the incident using the "PUT" method, any update in SN1 is not being reflected in SN2. For your reference, I am providing the BR below, would really appreciate some help here?

(function executeRule(current, previous /*null when async*/) {

// Add your code here

var body = {
"short_description": current.short_description.toString(),
"description": current.description.toString(),
"caller_id": current.getDisplayValue('caller_id'),
"state": current.getDisplayValue('state'),
"impact": current.getDisplayValue('impact'),
"urgency": current.getDisplayValue('urgency')
};

var corID = current.getValue('correlation_id');

try {
var r = new sn_ws.RESTMessageV2('TDC Integration', 'Default PUT');
r.setEndpoint('https://dev100277.service-now.com/api/now/table/incident/'+corID);
r.setRequestBody(JSON.stringify(body));

//override authentication profile
//authentication type ='basic'/ 'oauth2'
//r.setAuthenticationProfile(authentication type, profile name);

//set a MID server name if one wants to run the message on MID
//r.setMIDServer('MY_MID_SERVER');

//if the message is configured to communicate through ECC queue, either
//by setting a MID server or calling executeAsync, one needs to set skip_sensor
//to true. Otherwise, one may get an intermittent error that the response body is null
//r.setEccParameter('skip_sensor', true);

var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();

}
catch(ex) {
var message = ex.message;
}
})(current, previous);

   

 

17 REPLIES 17

Tried using the following as part of Update Flow. But getting error (please refer below):

Not sure why I am facing issues with incident UPDATE all the time.

 

find_real_file.png

find_real_file.png

 

 

find_real_file.png

 

 

 

As I mentioned earlier, Your Service account is missing incident update roles or may be the incident you are trying to update . Typically below roles are required to update via Rest Api.

  • rest_service
  • web_service_admin
  • itil

In addition to above if there are any custom ACLs are in place to restrict incident update to some specific role. Your Service account must have that assigned. 

 

Thanks & Regards,

Sharjeel

Regards,
Muhammad

Jeets
ServiceNow Employee
ServiceNow Employee

Try using Patch method and see if it works, we noticed few issues with put method.

Shantharao
Kilo Sage

Hi,

 

Are you using basic authentication with proper rest user credentials with proper access controls

 

Thanks

I am using basic auth credentials