- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on ‎04-30-2022 12:22 AM
We can utilize the Service catalog API to raise catalog requests from external applications when integrating third-party applications with ServiceNow.
We'll need two important APIs to submit the request 👇
> Add Item To Cart (POST)
> Submit Order (POST)
STEPS TO REPRODUCE
1.) Open REST API EXPLORER from Application navigator
2.) Choose Namespace as sn_sc and Select Add Item To Cart (POST)
3.) Upon selecting the Add Item To Cart (POST)
> To identify the Item Give the Catalog Item sys_id in path parameters
> Provide Request body in the Raw format
> For Example, I have selected the OOTB Standard laptop as Catalog Item
> Now give the request body, which should include the following information:
sysparm_also_request_for - Optional
sysparm_quantity - Required. Quantity of the item. Cannot be a negative number.
Data type: Number
Variables - Name-value pairs of all mandatory cart item variables. Mandatory variables are defined in the associated form.
Data type: String
Sample RAW format
{
'sysparm_quantity': 1,
'variables': {
'acrobat' : 'true',
'photoshop' : 'true',
'Additional_software_requirements' : 'Testing Service catalog API'
}
}
4.) Upon submission you should get the below response
5.) Now that the items have been added to the cart, we must submit the request using the Submit Order (POST) API.
6.) We can submit without giving any more information in the Request body after selecting the API. The ideal response should be as follows:
7.) You can check the Request by navigating to the Request form/RITM form, as shown below.
References :
Please give your valuable feedback and post comments if any corrections are required 😊
Regards,
Sai Kumar Bolisetty
Community Rising Star 2022
- 16,324 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Check this out, This might help : https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0686272/MyMercy.com
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Cant we do this by using a single API ?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Mishu If you wanna do it via REST API above mentioned is the process, If you want to create Requests from any of the server-side scripts you can use Cart API.
Sample code
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('e46305bdc0a8010a00645e608031eb0f'); //Pass catalog item sys_id
cart.setVariable(item,'os','Linux Red Hat'); //Set the variable value
var rc = cart.placeOrder(); //Place order
gs.addInfoMessage(rc.number); //Alert the Request number
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Sai Kumar B where to place the script in the API explorer and i cannot find the cart API on the left of the screen ?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hello @Sai Kumar B,
I put this into a script include to call these 2 APIs, but I ran into an issue where I need to Requested for to be someone else instead of myself after the Request is created. I altered the payload to
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi,
I see that in this article you simulate the calls from the API explorer within SNOW. but we were to use these calls from an external app, what is the supported authentication/authorization methods supported?