Service now REST API sysparm_limit usage issue

Anand Shenoy
Mega Contributor

Hi All,

I am using serviceNow Rest API calls to read the list of incidents created by particular user in specific time period. While doing so, I need tp pass sysparm_limit as mandatory parameter.

ISSUE: In particular case the user has only two tickets, One in Close and One in New, I am getting only one incident if I had the sysparm_limit parameter. Ex query is given below:

https://<instanceName>/api/now/table/incident?sysparm_display_value=true&sysparm_query=ORDERBYDESCsys_updated_on^sys_updated_on>=2017-05-05+16:23:13^sys_updated_on<=2020-09-06+16:23:13&caller_id=shenoy.it@gmail.com&sysparm_fields=number,state,short_description,comments%2Csys_updated_on,caller_id&sysparm_limit=5

 

But, If I remove the sysparm_limit parameter from the query, I am getting the actual incidents (Two incidents). But I need the sysparm_limit as mandate, since other users may have more incident on their names.

Please can you give guide me, if any changes has to be made in the query param.

TIA.

2 REPLIES 2

Pratiksha Kalam
Kilo Sage

Hi Anand,

The third party should send the sysparm_limit and sysparm_offset.

if your table doesn't have too many columns, 10000 record per transaction should be good.

 So the first one should be sysparam_limit=10000&sysparm_offset=0

next one should be sysparam_limit=10000&sysparm_offset=10000

sysparam_limit=10000&sysparm_offset=20000

 

If my reply helps you at all, I’d really appreciate it if you click the Helpful button and if my reply is the answer you were looking for, it would be awesome if you could click both the Helpful and Accepted Solution buttons!

 

Regards,

Pratiksha

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Anand,

this can happen only in scripted rest api where you have control over what response you want to send

below approach for scripted rest api

you need to get the url and check whehter sysparm_limit parameter is present in the url or not

var url = request.url;

var limitPresent = url.indexOf('sysparm_limit');

if(limitPresent < 0){

// it means 3rd party has not included that parameter so return error

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

 

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