REST API limiting on Sys User data

neha_joshi
Kilo Contributor

I am using REST API to query sys user table and get user information for around 100 users. I am specifying the user's sys_id in the sysparm_query as follows. The API works for only upto 45 sys_ids and fails there after. Is there any other way to get user info for a large number of users?

https://instance.service-now.com/api/now/table/https://optummasterdev.service-now.com/api/now/table/sys_user?sysparm_query=sys_id=3f611f6a4ffa42003e1223d18110c759^ORsys_id=3f611f6a4ffa42003e1223d18110...   and so on.....

4 REPLIES 4

cwjurges
Giga Contributor

Use Perspectium and you won't encounter this threshold...


tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Neha,



As an alternative to bringing the data back in one REST call by specifying a list of sys_ids you could make one call per sys_id and loop through the list of sys_ids.


Or maybe you could specify an encoded query?


If you can build a list of interesting users in a list view you can "copy query" and reuse it.



sys_updated_on>=javascript:gs.dateGenerate('2016-09-05','07:53:08')



curl "https://instance_name.service-now.com/api/now/table/sys_user?sysparm_query=sys_updated_on%3E%3Djavas...')" \


--request GET \


--header "Accept:application/json" \


--user 'admin':'admin'



BTW it could be you are building a URL that is too big - and that is why you are seeing a max limit of 45 sys_ids



Best Regards



Tony


JC Moller
Giga Sage

Hi,



Many browsers and application servers have limitations regarding REST API URL length.



http://stackoverflow.com/questions/2659952/maximum-length-of-http-get-request



I remember that we had issues with XML exports, when the URL was longer than 1000 characters (this was in Calgary/Dublin versions).



Your query has more than 1500 characters with 45 sys_id's. I recommend you to redesign your approach retrieving the data. Maybe create a virtual team or location in Servicenow and add users there, and then make the REST GET request based on this single value, that all the user's in question have in common. Then you maintain the data in Servicenow and don't have to change the integration end-point, when you make changes to user base the integration has to read.



- Jan


pavelmuller
Tera Contributor

The ServiceNow API has limits for the REST API responses, XML exports, etc. ServiceNow simply tries to avoid performance consequences of super-large data exports. It is not a good idea to increase the limits.



One option is to page through the data as suggested in the ServiceNow docs:


Break up a large export



However, then the scripts are becoming more complicated and hard to maintain. Perhaps you could build a copy of certain ServiceNow tables in your own database:


SnowMirror | The Smart Data Replication Tool for ServiceNow



Kind Regards,


Pavel