Service Catalog API - DELETE /sn_sc/servicecatalog/cart/{sys_id}/empty

This method deletes the cart and contents of the cart for a given user role and sys_id.

URL format

Versioned URL: /api/sn_sc/v1/servicecatalog/cart/{sys_id}/empty

Default URL: /api/sn_sc/servicecatalog/cart/{sys_id}/empty

Supported request parameters

Table 1. Parameters
Parameter Description
sys_id Indicates the sys_id of the cart to empty.

Headers

The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.

Table 2. Request headers
Header Description
None
Table 3. Response headers
Header Description
None

Status codes

The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, seeREST response codes.

Table 4. Status codes
Status code Description
204 Indicates that the request completed successfully and the items in the cart are successfully checked out.
400 Indicates an error for one of the following reasons:
  • Invalid CartId.
  • User does not have admin/catalog_admin role, and trying to empty another user cart.

User roles

Table 5. User roles to delete cart and cart contents
Role Description
admin/catalog_admin A user with this role can empty any user cart.
admin A user with this role can delete the cart after all the contents of the cart are deleted.
catalog_admin A user with this role can delete all the items in the cart.

Sample cURL request

curl "https://instance.service-now.com/api/sn_sc/v1/servicecatalog/cart/checkout" \
--request DELETE \
--header "Accept:application/json" \
--user 'admin':'admin'
None

Sample Python request

#Need to install requests package for python
#easy_install requests
import requests

# Set the request parameters
url = 'https://instance.service-now.com/api/sn_sc/v1/servicecatalog/cart/checkout '

# Eg. User name="admin", Password="admin" for this code sample.
user = 'admin'
pwd = 'admin'

# Set proper headers
headers = {"Content-Type":"application/json","Accept":"application/json"}

# Do the HTTP request
response = requests.delete(url, auth=(user, pwd), headers=headers  )

# Check for HTTP codes other than 204
if response.status_code != 204: 
    print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
    exit()

# Decode the JSON response into a dictionary and use the data
data = response.json()
print(data)
None