Inbound REST Scripted Web Service

harishdasari
Tera Guru

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

1 ACCEPTED SOLUTION

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:



find_real_file.png




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


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

View solution in original post

12 REPLIES 12

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Harish,



Following link explains you:



Import Set API - ServiceNow Wiki


REST APIs : import set tables



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

Hi Ankur,



Thanks for the response.



Actually our requirement is, bi-directional SMS.



I have configured outbound SMS in my system. it is working fine and no issue with that.



Now issue is when outbound SMS is triggered the third part system will send a response to the servicenow in JSON format, Now I have to capture this information using the inbound scripted web service and store into a custom table.



I haven't done the inbound REST integration before.



Could you please let me know what are the steps to fallow.



Thanks.



david-smith


Hi Harish,



I have not done it earlier. But I think it is similar to web service import set for soap and it is just that you need to provide the staging table name in the URL


example: /api/now/import/u_your_web_service endpoint as mentioned in the documentation.


Also similar to soap web service import set create transform map, field map , coalesce field etc.


Import Set API - POST /now/import/{tableName}



Will check and let you know.



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

Thank You Ankur.



When we provide scripted REST endpoint url to third party, they will send the response to servicenow.



Now our system should capture it into staging table and it should transform it into custom table.



I will wait for your update.



Thank you.