How to call pagination wise records throug REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2021 04:20 AM
Hi Experts,
I want to make a rest message call from third party where we can only retrieve 200 records at a time. They have 2000 records in total. My concern is how to paginate the url mutliple times when calling the rest API by scheduled job.
Ex: https://test.com/test/api/v1/data/details?.full=true&.firstResult=0&.maxResults=200
https://test.com/test/api/v1/data/details?.full=true&.firstResult=200&.maxResults=200
https://test.com/test/api/v1/data/details?.full=true&.firstResult=400&.maxResults=200
and so on....
I have checked many solutions but can not think how to use the solution.
Can anyone please guide me where I can use the query or how to achieve this ?
Any help would be really appreciated.
Thanks,
Nitin
- Labels:
-
IntegrationHub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2021 07:54 AM
Hi,
Where can I define the loop in the rest message. There is only the header and query parameters.
Could you please provide an example ?
Regards,
Nitin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2021 09:09 AM
Hi,
Can you please share sample JSON response?
And your API swagger definition where your API is documented.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2021 03:10 AM
Hi,
Below is the first line of the response when I am testing the rest message call.
<?xml version="1.0" ?>
<queryResponse last="199" first="0" count="1767" type="details" responseType="listEntityInstances" requestUrl="https://test.com/test/api/v1/data/details?.full=true&amp;.firstResult=0&amp;.maxResults=200" rootUrl="https://test.com/test/api/v1/data">

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2021 05:22 AM
Hi,
As this API Return 200 record, and based on count (i.e 1767) you need to make multiple call to same API
For example.
1. Make a call to root API <"https://test.com/test/api/v1/data>
2. Parse response and your can get the first 200 records. Also store the count in soem variable and make further call until you get all records:
var totalRec = responsebody.count; // i.e 1767
var receivedCount = 200;
while(receivedCount<totalRec){
// make another call to url = "https://test.com/test/api/v1/data/details?full=true&firstResult="+receivedCount+"&maxResults=200;
// make API call and parse next 200 records
receivedCount = receivedCount +199;
}
As you can see the result received has maxResults=200, you can try making API call with updated URL with value maxResults=2000.
Please check documentation for the same, same must be documented on 3rd part API documentation.
Thanks,
Anil Lande
Thanks
Anil Lande