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

Hi Harish,



Any update on this?


Can you mark my answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.



Regards


Ankur


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

Harish,   Did you get this integration working.   I'm kind of in the same boat myself.   I create a ZD ticket it goes over to Snow with no problem but I need to then update the ZD ticket with the SNow sys_id so my business rules will work.   Could you offer some in-site on how you accomplished this?


Hi Stephen,



What you can do is



1). Create script include and use the REST API GET method to retrieve the required details from external system and import them into a import set table.



2). Now create the scripted Rest API and use the script include which you have created and write those imported values to target table.



Thank you..


Ankur Bawiskar
Tera Patron
Tera Patron

Hi Harish,

Any update on this?
Can you mark my answer as correct, helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.

Regards
Ankur

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

harishdasari
Tera Guru

Hi Ankur,

 

Could you please help me on this thread below.

 

https://community.servicenow.com/community?id=community_question&sys_id=21619038dba5eb44f0612183ca9619ef

Thank you.