Send API link to Third Party team

Gowtham29
Tera Expert

Hi Team,

We have third party tool, team wants a URL they can use to insert a incident record in our instance. That URL should allow them to pass a variable, the phone number, using phone number I need to updated the requested for field so that ServiceNow can populate the customers profile / account information on that incident record.

Please help to build this URL ASAP. Thanks in advance.

4 REPLIES 4

AnveshKumar M
Tera Sage
Tera Sage

Hi @Gowtham29 

You need to develop a Scripted REST API or SOAP API. For example to develop REST API,

 

1. Navigate to System Web Services -> Scripted Web Services - Scripted REST APIs and click on new button.

Screenshot_2023-12-15-09-39-12-703-edit_com.android.chrome.jpg

2.  Then fill in the name for your API and click on submit.

Screenshot_2023-12-15-09-41-06-493-edit_com.android.chrome.jpg

 

3. From the list view open the records you just created and scroll down to the related list Resources and click on the new button, in the form opened fill in the details like below for Creation.

 

Screenshot_2023-12-15-09-46-44-666-edit_com.android.chrome.jpg

 

4. Use the following script

(function (request, response){

 

var data = request.body.data;

var usrGr = new GlideRecord('sys_user');

if(usrGr.get('phone', data.phone_number){

var incGr = new GlideRecord('incident');

incGr.initialize();

incGr.caller_id = usrGr.sys_id;

incGr.short_description = data.short_description;

//Map all the fields they pass like this

incGr.insert();

}

 

})(request, response)

 

 

5. Save the record. And it will go back to the previous page where you can see newly created POST resource along with the URL.

Screenshot_2023-12-15-09-52-13-505-edit_com.android.chrome.jpg

 

You can share this URL prefixed with ServiceNow instance address.

 

Please mark my answer helpful and accept as a solution if it helped 👍

Thanks,
Anvesh

Thanks Anvesh for the quick response, URL in the sense, the resource path right?
Can i test this URL using postman tool?

Ankur Bawiskar
Tera Patron
Tera Patron

@Gowtham29 

I would recommend scripted rest api or import set api depending on your requirement.

what did you start with and where are you stuck?

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

I didn't tried scripted rest API, I built link using REST API Explorer, it is creating record but it is not checking phone number and updating requested for field. The record is being inserted with requested for as empty.