- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 05:19 AM
Dear all,
Hello,
I simply need to place an order from Service Catalog by using SN REST Api,
The client is a chat bot
- the customer want to get its list of available assets in given category ( ex : computer).
- From the list of return assets, he will decide for instance to by a certain type of computer
- Then an order will be place and created for the item in order to place that Computer order with all details.
- The all information of created order should be send back to customer as part of web service response
Could you please describe more clearly :
- Which REST API tables will be used in order to complete the request and how many request should be send ?
( I have seen that order create a Request and Request Item in task table and then a link to sc_req_item table)
- How to return to client a formatted return response with collection of placed order information ? is it native or need to create custom web service to merge data in a single response ?
Thanks for help on this
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 08:00 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 06:53 AM
Hi,
To order a service request, servicenow has a separate API
https://docs.servicenow.com/bundle/jakarta-application-development/page/integrate/inbound-rest/concept/c_ServiceCatalogAPI.html
However, You can also create a scripted rest api, where you can accept array of JSON string and iterate through each using below API
var cartId = GlideGuid.generate(null); var cart = new Cart(cartId); var item = cart.addItem('e46305bdc0a8010a00645e608031eb0f'); cart.setVariable(item,'os','Linux Red Hat'); var rc = cart.placeOrder(); gs.addInfoMessage(rc.number);Details are available here
https://docs.servicenow.com/bundle/london-application-development/page/script/server-scripting/reference/r_ServiceCatalogScriptAPI.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 07:07 AM
The sample you provide is handing the shopping cart once you select the product correct ?
But before that what wold be the process for the following
1- Collecting Asset for a given category like "Computer"
2 - From the selected item by user then select all available possible configurable option like Hard drive size, memory size, operating system ( if exist)
3 once the all selection is full at that time only it can be place to shopping cart using your sample
So how to handle above steps, which API to be used on each step ?
I could not see the Service Catalog API in REST API Explorer, does it exist ?
regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 07:25 AM
Hi,
1- To get the list of all assets, you can use table apis to get it using GET method.
https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/integrate/inbound_rest/concept/c_TableAPI.html
2- To get all the variables available of a particular catalog, you can again query the table api and get all variable from table "item_option_new"
3 - this can be logic be built if, any one variable is blank, then throw an error
I suggest, use scripted rest api with cart api, this gives you more control over data flow and return body.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 07:35 AM
I jsut try the following you mention as :
To get all the variables available of a particular catalog, you can again query the table api and get all variable from table "item_option_new"
I get the root option using this like for instance os-platform, but then how can I get the choice option value inside os-platform variable as in UI it is choice box ?
regards