- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 12:55 AM - edited 12-05-2023 01:01 AM
Hi ServiceNow Community,
I have a requirement where I have to share the ServiceNow REST API Endpoint of few tables (Ex: Story, Project, etc) which will be used in Power BI to fetch data from ServiceNow to create reports. For this I have made use of the table API's which is working well if it has less data in the table.
Since we have lot of data stored in each of these tables, I am getting "Transaction time out error" after exceeding the defined time in "Transaction Quota Rule [sysrule_quota]" table of the record "REST Table API request timeout". Increasing the time limit to 5 mins (300 seconds) isn't also helping solve the issue which in turn is pulling few records only.
In order to get rid of this situation, I have been trying to split the endpoint in batches, where the first end point pulls records 1-1000, 2nd endpoint pulls the records from 1001-2000 and so on. However, it is will become a manual process and also ends up in using multiple endpoints in the 3rd party system as shown below.
Have done below as an alternative for time being -
Retrieve data in parts to decrease the transaction time :
- Records (1 to 1000)
https://instanceXYZ.service-now.com/api/now/table/pm_project_task?sysparm_query=parentISNOTEMPTY&sys... - Records (1001 to 2000)
https://instanceXYZ.service-now.com/api/now/table/pm_project_task?sysparm_query=parentISNOTEMPTY&sys... - Records (2001 to 3000)
https://instanceXYZ.service-now.com/api/now/table/pm_project_task?sysparm_query=parentISNOTEMPTY&sys... - Records (3001 to 4000)
https://instanceXYZ.service-now.com/api/now/table/pm_project_task?sysparm_query=parentISNOTEMPTY&sys...
We are currently using POSTMAN tool to test these endpoints and want to resolve the timeout issue.
I would like to know if there is any way to make use of the OOB table API to pull data from ServiceNow tables in batches using a single endpoint which can be later used in the third party system? Please help with detailed steps.
Thanks in advance!
Regards,
Shubha
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 09:21 AM - edited 02-07-2024 09:26 AM
Posting answer to my question after a while, hoping it helps someone. The below approach helped me achieve the desired results.
After doing a lot of research and going through the product documentation, community & KB articles it is recommendended to use the pagination technique.
To do this, the offset values needs to be adjusted by the third party system that is using the endpoints. they will have to develop a logic that involves loops to query the data in batches.
In my project scenario, as there are more number and records and the data size is also huge we suggested the third party tool member to pull the data in chunks by using pagination.
Please follow below document and use the method by adding sysparm limit and offset to your query for achieving this requirement.
KB0727636 - Exporting Bulk Data from Servicenow via REST Web Service Pagination
In addition to the above solution, I would like to add one more thing related to the same case - Is there a way where we can figure out the total number of records that exists in a table using the endpoint to set the sys_parm_limit value. Because setting the sys_parm_limit manually might be helpful initially, but as the record keeps increasing it would be good if have any OOB parameter that could be used for getting the dynamic count which could be used in the logic which sets the sys_parm_limit.
For the 2nd scenario mentioned above, it can be acheived using the aggregate API.
Please refer below doc.
Kindly mark this solution as helpful if it helps you or mark as solution accepted.
Regards,
Shubha S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 03:09 AM
The OOTB table API returns a header attribute "Link" which you can use to query next set. But, it depends on the third party tool capability to read the header in response and query the next link.
This will contain 3 links, first (current data returned), next (next page of data) and last (last page of data). From this we can use next link to query the next batch of data.
<https://devxxxxx.service-now.com/api/now/table/incident?sysparm_limit=10&sysparm_offset=0>;rel="first",<https://devxxxxx.service-now.com/api/now/table/incident?sysparm_limit=10&sysparm_offset=10>;rel="next",<https://devxxxxx.service-now.com/api/now/table/incident?sysparm_limit=10&sysparm_offset=60>;rel="last"
Please mark my answer helpful and accept as a solution if it helped 👍✔️
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 09:21 AM - edited 02-07-2024 09:26 AM
Posting answer to my question after a while, hoping it helps someone. The below approach helped me achieve the desired results.
After doing a lot of research and going through the product documentation, community & KB articles it is recommendended to use the pagination technique.
To do this, the offset values needs to be adjusted by the third party system that is using the endpoints. they will have to develop a logic that involves loops to query the data in batches.
In my project scenario, as there are more number and records and the data size is also huge we suggested the third party tool member to pull the data in chunks by using pagination.
Please follow below document and use the method by adding sysparm limit and offset to your query for achieving this requirement.
KB0727636 - Exporting Bulk Data from Servicenow via REST Web Service Pagination
In addition to the above solution, I would like to add one more thing related to the same case - Is there a way where we can figure out the total number of records that exists in a table using the endpoint to set the sys_parm_limit value. Because setting the sys_parm_limit manually might be helpful initially, but as the record keeps increasing it would be good if have any OOB parameter that could be used for getting the dynamic count which could be used in the logic which sets the sys_parm_limit.
For the 2nd scenario mentioned above, it can be acheived using the aggregate API.
Please refer below doc.
Kindly mark this solution as helpful if it helps you or mark as solution accepted.
Regards,
Shubha S