cancel
Showing results for 
Search instead for 
Did you mean: 

REST Get Pagination

leonardoamorim
New Contributor

Hi everybody,

I’ve been thinking about a solution to my problem the past few weeks and still couldn’t find a proper solution.

The problem is: I have an REST Output which gives me the following.
Screenshot 2021-04-26 at 16.18.07

The total of outputs I have for ONE day and the data with a limit of 100.
It doesn’t have the offset or number of pages in the output.

I want to fetch all the data for a day (in this case, 10811) so I created a MAPPER with the following values before asking for the REST GET with PAGINATION

Screenshot 2021-04-26 at 16.25.12

Then, I do a REST GET with the following values for:

  • from
  • to
  • type
  • limit (always a 100)

Screenshot 2021-04-26 at 16.27.00

The problem is when I try to do the pagination that does not work.

For the HasNext field: $entity.data.length > 1 (this is always true until it reaches the last offset value and it returns me an array with 0 data)
For the NextUrl fiel i have : “URL” + + “?from=” + $from + “&to=”+ $to + “&type=”+ $type + “&limit=”+ $limit + “&offset=” + (snap.out.totalCount+100).toString()

Screenshot 2021-04-26 at 16.30.45

I need to increment the OFFSET in the REST GET by 100 every iteration, with a LIMIT of 100 outputs every time, until I have all the TOTAL outputs (in this case, 10811).

I don’t know what I am doing wrong, but i’m getting an error:
“error”:“not found: unable to find valid operation for: null”,“code”:“S21”}"

Can someone help me? Thanks 😃

4 REPLIES 4

koryknick
Employee
Employee

I just did this recently and here was the solution I came up with. Assuming that the response provides the total number of records as “totalItems” in the response $entity object:

image

It appears you should be able to do something similar. Keep in mind that the Has Next and Next URL properties work from what you see in the output of the REST Get, so you will likely need to prefix your values with $original.

Kory, thank you so much for your help! I didn’t quite get it the $original. part, but it worked for me! many thanks!

@koryknick Hi Kory , Can you please help me to calculate has next and next url in rest get snap

rahulkalyanwat_0-1693812541716.png

 

sample API response 
{
"statusLine": {
"protoVersion": "HTTP/1.1",
"statusCode": 200,
"reasonPhrase": "OK"
},
"entity": {
"pageInfo": {
"totalCount": 918,
"startCount": 1,
"limit": 100
},
"usersDetailWithSubLocation": []

koryknick
Employee
Employee

@rahulkalyanwat - I would need more to go on to help ensure I have it right, but Has Next will be something similar to the following:

Has Next: ($entity.startCount + $entity.limit) < $entity.totalCount

I can't help with the Next URL without more information on the API such as any other query parameters you are using and what the pagination parameters are (skip/offset/page, limit/take, etc.)

PS - sorry it took a while for me to respond... I was on vacation.  I recommend that you open a new thread rather than replying to a post with secondary questions.  This can help ensure more community members see your question and will be likely to respond.

Hope this helps!