- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2017 03:35 AM
Hi
In Scripted REST web service, when Third party system sends response, it should come into servicenow.
I have created staging table and custom table.
Here Issue is how can I get values into staging table and how to make transformed into custom table.
can anyone please let me know the steps how to acheive this using scripted REST inbound web service
Thanks
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2017 05:32 AM
Hi Harish,
I developed it in my demo instance and here are the steps. Here you go:
1) Only POST and GET methods are supported.
2) Create web service import set, transform map and field map etc
a) Name of web service - REST API Import Set
b) Label - u_rest_api_import_set
c) 2 fields for testing Short Description(u_short_description) and Incident Number(u_incident_number)
d) Transform map
e) 2 Field maps for the above 2 fields with coalesce on incident number field.
3) Consuming the API: I tested this using Hurl.it - Make HTTP requests . This testing will allow you to understand how the client/end system will consume your REST API
Screenshot below:
a) Method - POST
b) Endpoint - https://instanceName.service-now.com/api/now/import/u_rest_api_import_set
c) Header -
i) Accept -> application/xml OR application/json (Response accepted will be in this format)
ii) Content-Type -> application/xml OR application/json (Request sent to Servicenow will be either XML or JSON based on this)
d) Request Body - this you will have to tell the client/user that you will accept in this sample request body.
{
"u_short_description": "hello122",
"u_incident_number" : "INC0010043"
}
e) Authentication - create a user with rest role and give id and password in that field. example: user id -> rest.user
Sample Response received as XML:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<import_set>ISET0010381</import_set>
<staging_table>u_rest_api_import_set</staging_table>
<result>
<display_value>INC0010043</display_value>
<sys_id>2a8c29254f500300fc11fa218110c7df</sys_id>
<transform_map>REST API Transform Map</transform_map>
<record_link>https://instanceName.service-now.com/api/now/table/incident/2a8c29254f500300fc11fa218110c7df</record_link>
<display_name>number</display_name>
<table>incident</table>
<status>inserted</status>
</result>
</response>
Sample Response received as JSON:
{
"import_set": "ISET0010381",
"staging_table": "u_rest_api_import_set",
"result": [
{
"transform_map": "REST API Transform Map",
"table": "incident",
"display_name": "number",
"display_value": "INC0010043",
"record_link": "https://instanceName.service-now.com/api/now/table/incident/2a8c29254f500300fc11fa218110c7df",
"status": "ignored",
"sys_id": "2a8c29254f500300fc11fa218110c7df",
"status_message": "No field values changed"
}
]
}
You can explore further on this as per your requirement.
Endorse the content if you feel this was helpful. How to Endorse Content
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2017 08:42 AM
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2017 03:16 AM
Hi Harish,
Inbound REST allows a third party to interact with data on a ServiceNow.
There are a number of REST APIs that are delivered with the product.
You can view these APIs by navigating to the REST API Explorer.
APIs included for Istanbul:
Table API - allows you to perform create, read, update, and delete (CRUD) operations on existing tables.
Aggregate API - allows you to compute aggregate statistics about existing table and column data.
Import Set API - allows you to interact with import set tables.
Attachment API - allows you to upload and query file attachments.
Performance Analytics API - allows you to query data about Performance Analytics scorecards.
User Role Inheritance API - allows you to see the roles that a specific user inherited.
IdentifyReconcile API - does clever stuff with the CMDB Identification and Reconciliation framework
CI Lifecycle Management API - Provides the ability to manipulate CI operational states and apply CI actions.
Service Catalog API - lets you access Service Catalog configuration and actions from within the Service Portal.
There may be some occasions when you want to do something that cannot be done with the REST APIs mentioned above.
In which case you can create your own scripted API.
The scripts will handle the request and response. You can define endpoints, query params and headers also.
So in answer to your inquiry - when should we use a scripted API - is when you need to do something that cannot be done with the OOB APIs.
If the reply was informational, please like, mark as helpful or mark as correct!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2019 06:05 AM
Hi Harish,
I'm working on the similar requirement. Can you share the business rule for update scenario, how are you checking if the incident already exists in another instance?