How to POST request from external application via ServiceNow scripted rest api?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2019 04:53 PM
I have realized that generating Incidents is pretty easy, since it is one record. Requests can be more difficult, because Requests can contain more than three records, Request, Requested Item, and Catalog Tasks. My goal is to create a bidirectional integration where if an outside application creates a service request, it will trigger a request within ServiceNow and vice versa. The POST component of this is what is giving me trouble. I have sought to create an inbound REST web service that points to the sc_item_option_mtom table, in order to pass in the RITM number to query the variable values on a specific from. Would anyone know a possible solution to this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2019 07:02 PM
You do not need to create custom REST API which create service requests.
Service now OOB provides service catalog REST API which external application can consume to create service request.
Please see below
https://docs.servicenow.com/bundle/london-application-development/page/script/server-scripting/reference/r_ServiceCatalogScriptAPI.html
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2019 06:45 AM
Ah ok that makes sense, so in using the OOB REST API, I noticed that there is an object called 'variable' that I could set the request variable names through (as shown below), in order to use the values that the user is passing through to the REST API should these variables be parameters within the REST API ?
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var cart = new sn_sc.CartJS();
var item =
{
'sysparm_id': 'dd46bcc313f7ab00a757fa82e144b0b5',
'sysparm_quantity': '1',
'variables':{
'location': '',
'requested_for': '',
'service_catagory': '',
'model_manufacturer': '',
'serial_no': '',
'asset_condition': '',
'model': '',
'manufacturer': '',
'ticket_type': '',
'summary': '',
'u_contact_type': '',
'u_phone': '',
'u_email': '',
}
};
var cartDetails = cart.orderNow(item);
gs.info(cartDetails);
})(request, response);