Table API - GET /now/table/{tableName}

This method retrieves multiple records for the specified table with proper pagination information.

URL format

Versioned URL: /api/now/v2/table/{tableName}

Default URL: /api/now/table/{tableName}

Supported request parameters

Table 1. Parameters
Parameter Description
sysparm_query Encoded query used to filter the result set.

For example:

(sysparm_query=caller_id=javascript:gs.getUserID()^active=true)

The encoded query supports order by. To sort responses based on certain fields, use the ORDERBY and ORDERBYDESC clauses in sysparm_query. For example, sysparm_query=active=true^ORDERBYnumber^ORDERBYDESCcategory filters all active records and orders the results in ascending order by number first, and then in descending order by category.

If part of the query is invalid, such as by specifying an invalid field name, the instance ignores the invalid part. It then returns rows using only the valid portion of the query. You can control this behavior using the property glide.invalid_query.returns_no_rows. Set this property to true to return no rows on an invalid query.
Note: This property controls the behavior of all queries across the instance, such as in lists, scripts (GlideRecord.query()), and web service APIs.
sysparm_display_value Data retrieval operation for reference and choice fields.
Based on this value, retrieves the display value and/or the actual value from the database.
  • true returns display values for all fields.
  • false returns actual values from the database. If a value is not specified, this parameter defaults to false.
  • all returns both actual and display values.
Note: There is no preferred method for setting this parameter. However, specifying the display value may cause performance issues since it is not reading directly from the database and may include referencing other fields and records. For more information on display values and actual values, see Table API FAQs (KB0534905).
sysparm_fields Comma-separated field names to return in the response.
sysparm_view UI view to determine fields returned in the response.
Note: If both sysparm_fields and sysparm_view are specified, the sysparm_fields parameter takes priority.
sysparm_limit Limit to be applied on pagination. The default is 10000.

Unusually large sysparm_limit values can impact system performance.

sysparm_offset Number of records to exclude from the query. Use this parameter to obtain more records than specified in sysparm_limit. For example, if sysparm_limit is set to 500, but there are additional records you want to query, specify a sysparm_offset value of 500 to get the second set of records. Do not pass a negative number in the sysparm_offset parameter.
sysparm_exclude_reference_link Additional information provided for reference fields, such as the URI to the reference resource, is suppressed.
sysparm_read_replica_category Category value to read data from read replicas.
Note: This parameter is not commonly used. The instance must have read replica support.
sysparm_suppress_pagination_header Set this value to true to remove the Link header from the response. The Link header enables you to request additional pages of data when the number of records matching your query exceeds the query limit.
Key-Value Pairs

Alternative to using the sysparm_query parameter. You can filter a query using key-value pairs where the key is the name of a field. This functionality is available for GET queries.

For example, instead of using the parameter &sysparm_query=active=true, you can use &active=true. You can use the display value when the field is a choice or reference type field, such as &state=closed instead of &state=7. To specify multiple key-value pairs, separate each with an ampersand, such as &active=true&assigned_to=john.smith.

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 REST API headers.

Table 2. Request headers
Header Description
None
Table 3. Response headers
Header Description
Link REST message data can be split into multiple result sets rather than forcing the user to submit multiple requests. The header has different links available for the first set, previous set, next set, and the last set of records, where applicable.

For example:

https://<instance name>.service-now.com/api/now/table/cmdb_ci?sysparm_offset=40&sysparm_limit=10000>;rel="next",

https://<instance name>.service-now.com/api/now/table/cmdb_ci?sysparm_offset=40&sysparm_limit=10000>;rel="prev",

https://<instance name>.service-now.com/api/now/table/cmdb_ci?sysparm_offset=0&sysparm_limit=10000>;rel="first",

https://<instance name>.service-now.com/api/now/table/cmdb_ci?sysparm_offset=2780&sysparm_limit=10000>;rel="last"
Note: The limit parameter defaults to 10,000 records. This limit can be set to any value. Be aware, however, that an unusually large value can impact system performance.
X-Total-Count Total count of records returned by the query.

Status codes

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

Table 4. Status codes
Status code Description
200 Request completed successfully. If a valid query returned no results, the response body contains only an empty result array.

Sample cURL request

curl "https://instance.service-now.com/api/now/table/problem?sysparm_limit=1" \
--request GET \
--header "Accept:application/json" \
--user 'username':'password'
{
  "result": [
    {
      "parent": "",
      "made_sla": "true",
      "watch_list": "",
      "upon_reject": "cancel",
      "sys_updated_on": "2016-01-19 04:52:04",
      "approval_history": "",
      "number": "PRB0000050",
      "sys_updated_by": "glide.maint",
      "opened_by": {
        "link": "https://instance.service-now.com/api/now/table/sys_user/glide.maint",
        "value": "glide.maint"
      },
      "user_input": "",
      "sys_created_on": "2016-01-19 04:51:19",
      "sys_domain": {
        "link": "https://instance.service-now.com/api/now/table/sys_user_group/global",
        "value": "global"
      },
      "state": "4",
      "sys_created_by": "glide.maint",
      "knowledge": "false",
      "order": "",
      "closed_at": "2016-01-19 04:52:04",
      "cmdb_ci": {
        "link": "https://instance.service-now.com/api/now/table/cmdb_ci/55b35562c0a8010e01cff22378e0aea9",
        "value": "55b35562c0a8010e01cff22378e0aea9"
      },
      "delivery_plan": "",
      "impact": "3",
      "active": "false",
      "work_notes_list": "",
      "business_service": "",
      "priority": "4",
      "sys_domain_path": "/",
      "time_worked": "",
      "expected_start": "",
      "rejection_goto": "",
      "opened_at": "2016-01-19 04:49:47",
      "business_duration": "1970-01-01 00:00:00",
      "group_list": "",
      "work_end": "",
      "approval_set": "",
      "wf_activity": "",
      "work_notes": "",
      "short_description": "Switch occasionally drops connections",
      "correlation_display": "",
      "delivery_task": "",
      "work_start": "",
      "assignment_group": "",
      "additional_assignee_list": "",
      "description": "Switch occasionally drops connections",
      "calendar_duration": "1970-01-01 00:02:17",
      "close_notes": "updated firmware",
      "sys_class_name": "problem",
      "closed_by": "",
      "follow_up": "",
      "sys_id": "04ce72c9c0a8016600b5b7f75ac67b5b",
      "contact_type": "phone",
      "urgency": "3",
      "company": "",
      "reassignment_count": "",
      "activity_due": "",
      "assigned_to": "",
      "comments": "",
      "approval": "not requested",
      "sla_due": "",
      "comments_and_work_notes": "",
      "due_date": "",
      "sys_mod_count": "1",
      "sys_tags": "",
      "escalation": "0",
      "upon_approval": "proceed",
      "correlation_id": "",
      "location": ""
    }
  ]
}

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/now/table/problem?sysparm_limit=1'

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

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

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

# Check for HTTP codes other than 200
if response.status_code != 200: 
    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)
<?xml version="1.0" encoding="UTF-8"?>
<response>
   <result>
      <parent />
      <made_sla>false</made_sla>
      <caused_by />
      <watch_list />
      <upon_reject />
      <sys_updated_on>2016-01-19 20:16:07</sys_updated_on>
      <child_incidents />
      <hold_reason />
      <approval_history />
      <number>INC0000001</number>
      <resolved_by>
         <link>https://instance.service-now.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441</link>
         <value>6816f79cc0a8016401c5a33be04be441</value>
      </resolved_by>
      <sys_updated_by>admin</sys_updated_by>
      <opened_by>
         <link>https://instance.service-now.com/api/now/table/sys_user/681ccaf9c0a8016400b98a06818d57c7</link>
         <value>681ccaf9c0a8016400b98a06818d57c7</value>
      </opened_by>
      <user_input />
      <sys_created_on>2014-05-20 18:24:13</sys_created_on>
      <sys_domain>
         <link>https://instance.service-now.com/api/now/table/sys_user_group/global</link>
         <value>global</value>
      </sys_domain>
      <state>7</state>
      <sys_created_by>pat</sys_created_by>
      <knowledge>false</knowledge>
      <order />
      <calendar_stc>7937181</calendar_stc>
      <closed_at>2015-10-20 23:10:06</closed_at>
      <cmdb_ci>
         <link>https://instance.service-now.com/api/now/table/cmdb_ci/b0c4030ac0a800090152e7a4564ca36c</link>
         <value>b0c4030ac0a800090152e7a4564ca36c</value>
      </cmdb_ci>
      <delivery_plan />
      <impact>1</impact>
      <active>false</active>
      <work_notes_list />
      <business_service />
      <priority>1</priority>
      <sys_domain_path>/</sys_domain_path>
      <rfc />
      <time_worked />
      <expected_start />
      <rejection_goto />
      <opened_at>2015-10-19 23:09:51</opened_at>
      <business_duration>1970-01-22 21:46:21</business_duration>
      <group_list />
      <work_end />
      <caller_id>
         <link>https://instance.service-now.com/api/now/table/sys_user/5137153cc611227c000bbd1bd8cd2005</link>
         <value>5137153cc611227c000bbd1bd8cd2005</value>
      </caller_id>
      <resolved_at>2016-01-19 19:56:12</resolved_at>
      <approval_set />
      <subcategory />
      <wf_activity />
      <work_notes />
      <short_description>Can't read email</short_description>
      <close_code>Closed/Resolved by Caller</close_code>
      <correlation_display />
      <delivery_task />
      <work_start />
      <assignment_group>
         <link>https://instance.service-now.com/api/now/table/sys_user_group/d625dccec0a8016700a222a0f7900d06</link>
         <value>d625dccec0a8016700a222a0f7900d06</value>
      </assignment_group>
      <additional_assignee_list />
      <business_stc>1892781</business_stc>
      <description>User can't access email on mail.company.com.</description>
      <calendar_duration>1970-04-02 20:46:21</calendar_duration>
      <close_notes>Closed before close notes were made mandatory</close_notes>
      <notify>1</notify>
      <sys_class_name>incident</sys_class_name>
      <closed_by>
         <link>https://instance.service-now.com/api/now/table/sys_user/9ee1b13dc6112271007f9d0efdb69cd0</link>
         <value>9ee1b13dc6112271007f9d0efdb69cd0</value>
      </closed_by>
      <follow_up />
      <parent_incident />
      <sys_id>9c573169c611228700193229fff72400</sys_id>
      <contact_type />
      <incident_state>7</incident_state>
      <urgency>1</urgency>
      <problem_id>
         <link>https://instance.service-now.com/api/now/table/problem/9d3a266ac6112287004e37fb2ceb0133</link>
         <value>9d3a266ac6112287004e37fb2ceb0133</value>
      </problem_id>
      <company />
      <reassignment_count>1</reassignment_count>
      <activity_due />
      <assigned_to>
         <link>https://instance.service-now.com/api/now/table/sys_user/46b87022a9fe198101a78787e40d7547</link>
         <value>46b87022a9fe198101a78787e40d7547</value>
      </assigned_to>
      <severity>1</severity>
      <comments />
      <approval />
      <sla_due />
      <comments_and_work_notes />
      <due_date />
      <sys_mod_count>21</sys_mod_count>
      <reopen_count />
      <sys_tags />
      <escalation>0</escalation>
      <upon_approval />
      <correlation_id />
      <location>
         <link>https://instance.service-now.com/api/now/table/cmn_location/1083361cc611227501b682158cabf646</link>
         <value>1083361cc611227501b682158cabf646</value>
      </location>
      <category>network</category>
   </result>
</response>