Notifications

25 views

Description

Symptoms


The table API is an out of the box feature and is ideal when integrating between third party applications

Resolution


If your REST remote application needs to send the query in a single URL, dedicated permissions need to be granted for the query to return results.

The REST Table API can be used as follow:

  • Table API - GET /now/table/{tableName}.  OR
  • Table API - GET /now/table/{tableName}/{sys_id}

You can also specified the version:

URL format

  • Versioned URL: /api/now/{version}/table/{tableName}
  • Default URL: /api/now/table/{tableName}

The REST Table API has some request parameters.

For example, this Table API REST query returns all the incidents where the priority is low and active is true

Example incident Table API query:

https://xxxxxx.service-now.com/api/now/table/incident?sysparm_fields=number,caller_id&sysparm_query=active=true^priority=4

the sysparm_fields provide a list of the fields that should be returned and the sysparm_query lets you specify the filtered query.

When dealing with Large result sets, use the sysparm_offset with sysparm_limit parameters

So let us say that there are 2500 rows but that is too much in one go, so you only want to return up to 500 rows at a time, to avoid performance issues. You need to return the first batch of 500 and then, the next 500 records and so on up to the point where you return all of the 2500 rows in 5 batches.


Here are the 5 batches /queries that will return 5 slices of the result set of the table expected to be around 2500 records large.

https://xxxxx.service-now.com/api/now/table/incident&sysparm_limit=500&sysparm_offset=500
https://xxxxx.service-now.com/api/now/table/incident&sysparm_limit=500&sysparm_offset=1000
https://xxxxx.service-now.com/api/now/table/incident&sysparm_limit=500&sysparm_offset=1500
https://xxxxx.service-now.com/api/now/table/incident&sysparm_limit=500&sysparm_offset=2000
https://xxxxx.service-now.com/api/now/table/incident&sysparm_limit=500&sysparm_offset=2500

Be careful that not too many rows are returned, otherwise this will impact the performance of your instance, if you do need to return large results sets, then the sysparm_offset should be used.

 

Warning: Be careful that this API also lets you delete tows if ACLs permit, ensure that only the relevant access rights are granted

 

Article Information

Last Updated:2019-08-02 20:42:40
Published:2019-05-22