Query on updating a incident record using REST message

varunkumar1
Tera Contributor

Hi Team,

 

I am doing servicenow - servicenow integration using REST table API. I am done with incident POST method and now working on  PUT method. when I am testing PUT operation using REST API Explorer using Table API, I selected table name as incident and mentioned the sys_id of the record to be updated. When I tested it is showing 200 OK. Now I am configuring PUT method in REST Outbound I have given the end point that I copied while testing in the REST API explorer

https://dev61095.service-now.com/api/now/table/incident/35d2e7a9db77130080789b81ca9619e7?sysparm_fields=sys_id%2Cnumber

And during testing from REST outbound, it is updating the record with sys_id that is present in the above URL. What am I suppose to do to overcome this problem. Even time when I test the PUT method, it is updating the same record of the sys_id 35d2e7a9db77130080789b81ca9619e7

I know that changing sys_id from the above URL will make corresponding record to get update. But I don't want to change URL manually every time in the PUT method in the REST message.

Please help me with the solution for this problem 

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Varun,

Have a variable for rest message and use variable substitution in the url.

https://docs.servicenow.com/bundle/kingston-application-development/page/integrate/outbound-rest/concept/c_VariableSubstitution.html

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

simonbergstedt
Tera Guru

If you change the endpoint in the outbound put message to this you will use a variable instead. After it's been saved click "Generate variables" and "Scipt usage" and you will see how it works.

 

https://dev61095.service-now.com/api/now/table/incident/${sys_id}?sysparm_fields=sys_id%2Cnumber

varunkumar1
Tera Contributor

Hi Ankur and Simon,

 

Thanks for the response.

As you susggested instead of sys_id, I used number variable in the URL 

https://dev61095.service-now.com/api/now/table/incident/$number?sysparm_fields=sys_id%2Cnumber

and when I tested from the REST outbound it showing the below error

"Record doesn't exist or ACL restricts the record retrieval"

 

I checked the incident table, it has "Allow access to table via web services" option checked. Not sure what is causing the issue.

Please share your thoughts on this issue.

find_real_file.png

Hi Varun,

your endpoint should contain variable substitution as ${number} and when you run it from business rule or some server side you need to substitute it.

example below:

var number = 'INC001';

r.setStringParameter('number', number);

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader