The CreatorCon Call for Content is officially open! Get started here.

About the GET method of the Table API

Koki
Tera Contributor

Hello.

 

I need to retrieve some record information from several tables using ServiceNow's REST API and use it outside of ServiceNow.

Is this possible with a single REST API call?

Can someone please share with me the best practices to make this possible using ServiceNow's REST API?

1 ACCEPTED SOLUTION

Hi,

Is the aim to import data into ServiceNow?

There is 2 approaches. The first is to export ServiceNow's master table to external service and have the external service specify ServiceNow's sys_id.

The second approach is to to import keys used by the external services into ServiceNow. ServiceNow has "correlation id" and "correlation display" to hold keys and description used by external services. Correlation id may be used to match the records when importing data ('remote correlation ID' in the following page).

https://docs.servicenow.com/bundle/quebec-servicenow-platform/page/administer/integrationhub/concept...

ServiceNow's integration hub is using the 2nd approach. That is, instead of exporting sys_ids, import keys used in external service into ServiceNow. Keeping the "single source of truth" on ServiceNow is the recommended way.

Which approach to take will depends on where job scheduling is to be done. It's better to keep job scheduling in 1 place so lessen cost and time of operation.

If taking the 1st approach, table APIs will suffice.

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

It depends

Using Table API of incident you can fetch incident details and details of reference fields by dot walking

Better to go with Scripted REST API so that you can fetch data from several tables and send that as response.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

suvro
Mega Sage

Hi Koki,

 

You can go through below community thread reading Batch API, may this is what you are looking for

https://community.servicenow.com/community?id=community_blog&sys_id=0a01fcc4dbcce740200f0b55ca9619cd

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Koki,

First, check if ServiceNow's API are accessible in the instance. Some users using SSO have reported that admin have disabled ServiceNow's API in their instance.

Second, REST API have size limitation. So, don't try to download too large of a file because it may timeout or get truncated by maximum file size settings. The setting may be increased but increasing it may hurt instance's performance.

Third, what format should the data be? If the data should be in CSV, make several API calls.

Fourth, what is the security requirement? Table API access security is based on the table. That is, the user would require read access to all the tables.If there is a requirement to set security per API, create a Scripted REST API. Scripted REST API runs on the server and ACL may be set on the endpoint.

>I need to retrieve some record information from several tables

Fifth, are the tables dependent on each other or separate tables. To keep dependency, it may be better to create Scripted REST API and return the result in nested JSON or XML. 

e.g.

https://qiita.com/htshozawa/items/4d32e77bb4fd20358695

 

 

Thank you.

Regarding the first, I was able to add a record to ServiceNow using the Table API (POST). I am aware that this is "accessible", is this correct?

Regarding the second point, I believe that the data is not that large since I am retrieving one record from each table at a time.

Regarding the third, what I would ultimately like to achieve is to add a record to a certain table from the outside.
However, that "certain table" has multiple reference type fields. In such a case, I am aware that I need to first get the sys_id of the referenced fields.
That is why we say "I need to retrieve some record information from several tables".
The sys_id must be in a format that can be used when adding a record, which is the ultimate goal, but we don't know much about what format that is, etc.

As for the fourth, I think the security set for the table is fine.

Regarding the fifth, I believe that each of the multiple tables is a master table and is a "separate table".