Making REST call pagination wise to retrieve records

Mason5
Mega Expert

Hi All,

How can we create outbound REST web-service to allow third party app, to retrieve only specific set of records(like 10 records) and at 3rd party side when user hit Next, then provide/send next 10 records? is it possible to achieve?

 

Many thanks in Advance 

1 ACCEPTED SOLUTION

Ujjawal Vishnoi
Mega Sage
Mega Sage

Hi Mason,

There are two ways of achieving this
1. In first approach, third party will have to change the parameter with incremented number

You can make use of the sysparm_offset and sysparm_limit parameters.
For example: If you want to retrieve 10 records (sysparm_limit=10) in the record set starting from the beginning (sysparm_offset=0) of the record set.

/api/now/table/<tablename>?sysparm_limit=10&sysparm_offset=0


Then for next 10 records, you would simply increment the value of sysparm_offset by the value of your sysparm_limit

/api/now/table/tablename?sysparm_limit=10&sysparm_offset=10

/api/now/table/tablename?sysparm_limit=10&sysparm_offset=20

/api/now/table/tablename?sysparm_limit=10&sysparm_offset=30

.

.

/api/now/table/tablename?sysparm_limit=10&sysparm_offset=n


2. Create a Scriptted rest API and on each call you can store the record set in a log table and send only those records those are not avaible in the log table.

Hope this helps!


Regards,
Ujjawal

View solution in original post

6 REPLIES 6

Ujjawal Vishnoi
Mega Sage
Mega Sage

Hi Mason,

Please mark answer correct if my solution resolved your issue, sothat it can be removed from unanswered list.

Regards,

Ujjawal

Niamul Arifin
Tera Expert

@Ujjawal Vishnoi I saw your accepted solution and would like to understand better for the 2nd approach

2. Create a Scriptted rest API and on each call you can store the record set in a log table and send only those records those are not avaible in the log table.

Could you please explain how to implement this solution.

Thank you