Send API link to Third Party team
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2023 07:56 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2023 08:23 PM
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.
2. Then fill in the name for your API and click on submit.
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.
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.
You can share this URL prefixed with ServiceNow instance address.
Please mark my answer helpful and accept as a solution if it helped 👍✅
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2023 08:36 PM
Thanks Anvesh for the quick response, URL in the sense, the resource path right?
Can i test this URL using postman tool?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2023 08:37 PM
I would recommend scripted rest api or import set api depending on your requirement.
what did you start with and where are you stuck?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2023 08:51 PM
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.