How to update record with REST API using correlation id?

Rajani1
Tera Contributor

Hi All,

I have set up ebonding between two instances and populating the incident number in the correlation ID field on POST. I am having difficulties with PUT as I am not sure how to update with the correlation id being incident number.  Can anyone please help me to figure out the right endpoint URL?

Thanks

 

My set up:

After BR on Incident table on update:

 

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

var body = {
"short_description": current.short_description,
"state": current.getValue('state'),
"work_notes": current.work_notes.getJournalEntry(1).toString(),
"hold_reason": current.getValue('hold_reason'),
"comments": current.comments.getJournalEntry(1)
};

try {
var r = new sn_ws.RESTMessageV2('Incident Demo Create', 'Update Incident');
var cor = current.getValue('correlation_id');
r.setEndpoint('https://myinstance.service-now.com/api/now/table/incident/' + cor);
r.setRequestBody(JSON.stringify(body));
var response = r.execute();
var req = r.getRequestBody();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
} catch (ex) {
var message = ex.message;
}

PUT endpoint is as below:

Rajani1_0-1676388529824.png

 

3 REPLIES 3

Rajani1
Tera Contributor

@Ankur Bawiskar @Ashutosh Munot1 

Can the experts please suggest

Rajani1
Tera Contributor

Can any experts please help..

snow2p
Tera Expert

You can use the API explorer. I linked a generic link in my post where I talk about using it. Just replace my instance with your instance. https://www.servicenow.com/community/developer-forum/api-explorer-is-not-updating-correlation-id-pro...