Scripted REST API for inbound integration

harishdasari
Tera Guru

Hi,

I have a requirement like, when user update state, Comments, Priority etc.. in third party application, then it should be updated in servicenow

I am using the scripted rest api PUT method to update the fields in servicenow.

Could you please help,

Script Include:

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Hi Harish,



As you said when ticket is updated in third party application then it should update the same in ServiceNow.


Are you saying that you have exposed the Scripted REST API to the third party.



I could see that you have used PUT method i.e. fine.



But the way you are fetching the response is incorrect . use following


var requestBody = request.body.dataString;



try to add logs to check requestBody is received correctly in your scripted rest api resource



also you are not sending the id as json key while consuming the REST endpoint so how you will get the value by parsing the json



the json parsing you have used is not correct. use following



var parser = new global.JSON();


var parsedData = parser.decode(requestBody);



var id = parsedData.work_notes;



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


Thanks


Ankur


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

View solution in original post

19 REPLIES 19

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

Have you used the REST API explorer to test if the incident can be updated correctly?



https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/integrate/inbound_rest/task/t_Exp...


Hi Sergiu,



Yes I have tested with REST explorer and it is working good.



Now What is the next step to make fields and worknotes update in servicenow.



Thank you


Can you login in the instance using REST details and update incidents?


harishdasari
Tera Guru

Hi Ankur,


bawiskar,



Could you please provide me some help on Inbound Ticket updation.


when state is changed in third party application, then it should update the same in servicenow.


Script include which I posted is not triggering and I am not getting what is the issue.



Thanks.