Handling REST API Pagination

Hi,

My REST API endpoint will be has below

/course?startPage=1

The "startPage" need to be incremented by 1 till there records are available in response and sample response body will be has below

{
  "page_of_records": [
    {
      "record": {
        "totalResults": 72080,
        "hasMoreResults": true,
        "startIndex": 1,
        "itemsPerPage": 10,
        "results": [
          {"title": "xxxxxxx","id": "xxxxxxx","href": "xxxxxxx"}, 
{ "title": "xxxxxxx", "id": "xxxxxxx", "href": "xxxxxxx" },
-----------
], "facets": [] } } ] }

How do I set the pagination?
0

Comments

11 comments
Date Votes
  • Hi Kiruba Devarajan,
    Thanks for posting this question. I'm checking with our experts and will let you know asap.

    0
  • Hi Kiruba,

    I'm going to take my best guess based on the info you've provided.

    1. Set the relative URI in your export to

    /course?startPage={{{export.http.paging.page}}}

    2. Set the paging method to "Page" and configure a couple of the other fields as follows. (Note that the above relative URI only works when the paging type is set to "Page".)

    The one thing I'm not sure about is whether the API returns a different status code ("Last page status code").

    Anyway, please give this a try and let us know how you go.

    Thanks,

    Matt

    0
  • The above is applicable if your endpoint is HTTP-based, but if it is REST, the settings are slightly different. (We've had to make this pretty flexible because paging HTTP/REST APIs can be implemented in lots of different ways).

    1. Set relative URI to /courses

    2. "Page argument" would be "startPage", and Max count path would be "totalResults". This will automatically add "?startPage=xxx" to the relative URI, and will use "totalResults" to know when to stop making calls. You can also use "Last page" info per my earlier post, depending on the application's response.

     

    0
  • Hi Matt Graney,

    Thank you for quick response. I have tried your first response by configuring API call as HTTP instead of REST API. Use to get the below error when previewing data.

     

    {
      "errors": [
        {
          "field": "http.paging.page",
          "code": "invalid_field",
          "message": "Cast to Number failed for value \"startPage={{{export.http.paging.page}}}\" at path \"http.paging.page\""
        }
      ]
    }

     

     

    0
  • Hi Matt Graney,
    After lot of tries, Iam able to succeed the pagination with your second response related to REST API by setting "Max count path" field to "totalResults".

    There where was some migration issue in lookup configuration which is next in flow. Recreated the lookup and issue is solved.

    Thankz for your help. Much Appreciated.

    Warm Regards,

    Kiruba Devarajan

     

    0
  • Hi Kiruba Devarajan,

    Thank you so much for letting us know! If you have a tip that could help others who are encountering this same issue, we would love it if you'd share it here! Thanks so much for contributing to our community knowledge!

    0
  • Hi Courtney Jordan,

    Thank you for quick turn around and knowledge flow.

    One thing I have noticed is {{{export.http.paging.page}}} is not working in HTTP API call. Similarly when we type "{{{" or "{{" in "Build relative URI handle bar template" we dont get "export" object there. If we address this issue, it would be helpful for beginners like me for quick learning.

    Warm Regards,
    Kiruba Devarajan

    0
  • That's great information, Kiruba Devarajan - thank you! I'll have our team look into this asap.

    0
  • Thanks for the feedback, Kiruba Devarajan, glad you got it working! 

    0
  • I am also struggling to get my pagination work. Do we have any latest article which summarize what all configs work.

    0
  • Hi Abhinav Kaushal,

    Since every connector varies for pagination, we don't have information available for every connector. Which application connector are you using? What errors are you getting? 

    0

Please sign in to leave a comment.

 

Didn't find what you were looking for?

New post