ServiceNow Service Catalog API Cart issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2018 08:19 AM
We have written a integration with ServiceNow to create Service Request ticket on ServiceNow using Service Catalog API - https://docs.servicenow.com/bundle/jakarta-application-development/page/integrate/inbound-rest/conce....
Background
The ticket creation process that is provided by Service Catalog API is two steps process :
- Add an item to cart using API - /sn_sc/servicecatalog/items/{sys_id}/add_to_cart
- Submit order using API - /sn_sc/servicecatalog/cart/submit_order
Issue
We are using above two APIS for ticket creation. Also we are using a single user for authentication in our integration. The issue we are facing is if two concurrent request comes for adding item to cart, they both are added to the same cart which results in creation of single ticket. Check below detail:
Example/Naming convention
Admin user for authentication = John.Doe
Request from our integration — IREQ
ServiceNow ServiceNow Request — REQ and RITM
Scenario
- Integration receive an request IREQ1 and it sends one add item request to the add_to_cart API using user John.Doe and item is added to cart.
- Even before integration submits the cart for the first request IREQ1, integration receives a concurrent request IREQ2 which is sent to the add_to_cart API using the user John.Doe, and item is added to the same cart created by first request IREQ1 — which is problem, here we expect a separate cart to be created for new request from our integration.
- Integration hit the submit order API, for first request IREQ1 but it results in creation of a ticket with two Requested Items (RITMS) as the cart contains two request (REQ1 with RITM1 and RITM2)
- Integration hit the submit order API, for second request but it receives 400 Bad Request error (Cart is empty!) because cart was never created for the second request.
Question
- Is there a way by which we can send any parameter in REST request so that it distinguishes the two requests i.e. IREQ1 and IREQ2 and creates separate cart and ticket for both.
- We come across a thread(https://community.servicenow.com/thread/285856) on the ServiceNow community which talks about the same issue and a possible solution. Is that the best way to solve the issue?
- Labels:
-
Integrations
- 4,011 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2019 05:17 AM
Hi Team,
We are using Madrid instance, still facing same issue.
Is there any way to create cart and then add item to cart and submit?
So that if same user logged in from different sessions can add items to cart and both can submit respective catalogs items which results in two different service request.
Current behavior of OOTB rest endpoints:
From Chrome browser, login to Madrid ServiceNow instance, using rest API Explorer, perform add item to cart
From Internet Explorer browser, login to Madrid ServiceNow instance, using rest API Explorer, perform add item to cart.
Here responses from both the clients i.e Chrome and Internet Explorer, returns same cart id.
Is there any OOTB way by which different clients returns different cart id for the session?
Thanks
Ajit