Service Catalog Rest API - order_now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2020 06:38 AM
Hi Experts,
I am novice to service now platform and trying to figure out Service Catalog Item integration through Rest API.
Using baseline endpoint of order_now:
https://server.service-now.com/api/sn_sc/servicecatalog/items/{sysid}/order_now
1. How to populate Requested_for column of sc_request or sc_req_item?
We have custom variable set to capture requested_for and other info of user, however that works only for manual submission of catalog item.
2. Is there anyway to pass sysid of catalog item record in the json payload instead in the URI?
We have an enterprise api repository(wso2 api manager) where we will be hosting the end points to be accessible by other applications and for service catalog endpoints we cannot have a constant sysyid in the URI.
Thanks in advance.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2020 04:08 PM
Hi,
To set variables, you need to supply a JSON body containing the name:value pairs desired.
curl "https://instance.service-now.com/api/sn_sc/servicecatalog/items/d82ea08510247200964f77ffeec6c4ee/order_now" \
--request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data "{
sysparm_quantity: 1,
variables: {
"requested_for":"<sys_id_of_user>",
replacement: 'Yes',
originalnumber: '1640000',
data_plan: '500MB'
}
}" \
--user 'username':'password'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2020 04:13 AM
Thanks Kieran. This way we can just populate the variable variablerequested_For not the table field requested_for in sc_request or sc_req_item.
I was able to do that by the work flow written on sc_req_item, however requested_for gets updated after the insertion.
var req = new GlideRecord('sc_request');
req.get(current.request);
req.requested_for = user_sysid;
req.update();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2020 04:27 AM
Hi,
The value should auto-map on sc_req_item as the variable and field names match.
Regarding sc_request, I've used a before insert BR to get the requested_for value:
(function executeRule(current, previous /*null when async*/) {
var grReqItem = new GlideRecord('sc_req_item');
grReqItem.addQuery('request', current.sys_id);
grReqItem.query();
while (grReqItem.next()) {
if (!JSUtil.nil(grReqItem.variables.requested_for)) {
current.requested_for = grReqItem.variables.requested_for;
}
}
})(current, previous);