You are currently viewing Create Request via REST API -Service Catalog API Demo

Create Request via REST API -Service Catalog API Demo

Using the OOB ServiceNow APIs, you can easily create a ServiceNow request. We can do this via ServiceNow’s REST API Explorer.

In this post, I will demonstrate the process of creating or submitting a request via the Service Catalog API.

Steps To Create RITM Using API

  • Go to System Web Service -> REST API Explorer
  • In API Explorer, set
    • Namespace=sn_sc
    • API Name: Service Catalog API
    • API Version=Latest
  • Scroll down and click on Buy Item (POST) method
  • Now under Prepare Request->Path parameters, provide the sys_id of the catalog item to be ordered.
  • Set the value of Authorization as Send as me in case you are using your admin account to authenticate
  • Otherwise, add the authorization header values by clicking the Add Header button
  • Now provide the Request Body values as Raw and add the below values according to your catalogue item and its variables
    • sysparm_id– sysID of catalogue item
    • sysparm_quantity– number of items to be ordered
    • variables -provide values to variables comma separated one by one
        'sysparm_id': '186d917a6fab7980575967ddbb3ee4f2',
        'sysparm_quantity': '1',
        'new_email': '' 
  • Click On Send.
  • The request was Successfully Submitted and received a response of 200 (OK)
  • The response body has details about the newly created request.

Sample Script To Use Service Catalog API In ServiceNow

Use the provided code samples to send this request from commonly used languages.

var request = new sn_ws.RESTMessageV2();
// Authentication
var user = 'admin';
var password = 'your password';
request.setRequestBody("{'sysparm_id': '186d917a6fab7980575967ddbb3ee4f2','sysparm_quantity': '1','variables':{'new_email': ''}}");
var response = request.execute();
gs.print("body - "+response.getBody());

Sample Script To Use Service Catalog API In Python

#Need to install requests package for python
#easy_install requests
import requests
# Set the request parameters
url = ''
# 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 =, auth=(user, pwd), headers=headers ,data="{
        'sysparm_id': '186d917a6fab7980575967ddbb3ee4f2',
        'sysparm_quantity': '1',
        'new_email': ''
# Check for HTTP codes other than 200
if response.status_code != 200: 
    print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json())
# Decode the JSON response into a dictionary and use the data
data = response.json()

Leave a Reply