Forum Discussion

rahulkalyanwat's avatar
rahulkalyanwat
New Contributor
2 years ago

Rest GET Pagination Issue

I am trying to read documents for REST GET snap and for specific ID i am having 918 records and I am only able to access starting 100 record and am not able to traverse next records. 

Sample response:

 

HAS NEXT and NEXT URL :

$entity.pageInfo.totalCount > 100*snap.out.totalCount

_BaseUrl+'/submgmt/api/v1/subscriptions/'+$ID+'/users?skip='+(100*snap.out.totalCount)+'&take=100'

 

7 Replies

  • chmurray88's avatar
    chmurray88
    New Contributor II

    following. I have a similar issue, but no count, limit, start.

    • RogerSramkoski's avatar
      RogerSramkoski
      Employee

      Hi chmurray88! Am I understanding this correctly that you have an API that is giving you a page of responses, but you don't have any count, limit, start, or similar variables to work with? Are you able to cleanse the data content and show what your response looks like?

  • Hello rahulkalyanwat, what happens with the 'Has next' and 'Next URL' that you have configured? Does it give you an error, or just never runs again? The response screenshot with "startCount" = 101 makes me think you did fetch a second page of results so I just want to clarify that.

    Next URL

    I would also ask if you're using the 'REST Get' or 'HTTP Client' Snap? The latter might make this a bit easier for the 'Next URL'. The screenshot below shows a pagination setup I use against SnapLogic's API and you can see I don't have to work with the 'Next URL' at all since SnapLogic can piece it together for me - all that was needed in this situation was to override the 'offset' parameter. Based on what I can see from your override URL "skip" would be the only parameter to override and you could use a value like '$entity.startCount + $entity.limit'. 

     
     
     

     

    Has next

    For the 'Has next' you could also use this expression so all the variables are based on values from the response instead of trying to use a static '100' and the internal 'snap.out.totalCount':

     

    $entity.startCount + $entity.limit >= $entity.totalCount

     

     

    • rahulkalyanwat's avatar
      rahulkalyanwat
      New Contributor

      Hi RogerSramkoski  I am Using REST Get snap and Copied Screenshot of Second Page and can you please help me to calculate nexturl as well.

      Page 1 response:

      REST GET Snap HAS NEXT and NEXT URL:

       

       

  • Hello rahulkalyanwat! Assuming that 'skip' is the correct query parameter and the rest of the URL is accurate, you could replace the expression at the end: 

    (snap.out.totalCount + 1).toString()

    with this:

    ($entity.startCount + $entity.limit)

     One thing I can't see in the previous screenshots though is your initial 'startCount' value. From the response in the original post it looks like 101 already. You may need to double-check that since every API can be different, though typically they would start at record 0 or 1, meaning the first page would be 0-99 or 1-100, next page would be 100-199 or 101-200