Blog

Five Example JSON Requests

JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy to parse and generate.  The ServiceNow JSON v2 web service operates on the JSON object as the data input and output format.

Having the JSON object available as a data format for web services means that you can create (insert), update, and query any data in your ServiceNow platform using the JSON object format, and get results in the JSON object format.

The JSONv2 web service is available in all instances starting with the Dublin release.  This article shows a variety of example JSON web service requests you can make with ServiceNow.

You can use a variety of tools to practice with JSON.  Sometimes I use Hurl.it, but there are many other tools you can use as well. 

Example 1: Find a record in the Location Table

Destination: GET: <your_instance>.service-now.com/cmn_location.do?JSONv2&sysparm_action=getRecords&sysparm_query=name=Colombia^city=Colombia
Authentication (Basic) Username/Password
Headers: Content-Type | application/json

Example 2: Find Records opened today in the Incident Table

Destination: GET: <your_instance>.service-now.com/incident.do?JSONv2&sysparm_action=getRecords&sysparm_query=active=true^sys_created_onONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0)
Authentication (Basic) Username/Password
Headers: Content-Type | application/json

Example 3: Insert a new record into the Location Table

Destination: POST: <your_instance>.service-now.com/cmn_location.do?JSONv2&sysparm_action=insert
Authentication (Basic)
Username/Password
Headers: Content-Type | application/json
Parameters +Add Body
{"name":"Mike","city":"Sebeka","state":"MN"}

Example 4: Find all users with Last Name starting with Kaufman and return display values

Destination: GET: <your_instance>.service-now.com/sys_user.do?JSONv2&sysparm_query=GOTOnameLIKEKaufman&displayvalue=true
Authentication (Basic) Username/Password
Headers: Content-Type | application/json

Example 5: Find all users with Name containing Mike and order by Last Name

Destination: GET: <your_instance>.service-now.com/sys_user.do?JSONv2&sysparm_query=GOTOnameLIKEMike&ORDERBYlast_name
Authentication (Basic) Username/Password
Headers: Content-Type | application/json