How to add pagination to REST end points and use parameters

  1. 1. In the application, go the end point

    In the application, go the end point

Postman

  1. 2. Look at the starting situation, without pagination

    By default, it returns the first 1000 rows.

    Look at the starting situation, without pagination
  2. 3. Add the built-in parameter page to activate pagination

    This doesn't require additional configuration. The first page = 1.

    Add the built-in parameter page to activate pagination
  3. 4. See the result. In the head of the request, you see the pagination

    This works when 'custom response' is of.
    In the version of the screenshot, there's a bug visible for 'total_pages', which is likely to be solved in April 2024.

    See the result. In the head of the request, you see the pagination
  4. 5. In Novulo, see how enabling 'custom response' breaks the pagination info

    In Novulo, see how enabling 'custom response' breaks the pagination info
  5. 6. Click here

    Click here
  6. 7. Save

    Save

Postman

  1. 8. Refresh the end point

    As you see, the custom response setting removes the header and doesn't show pagination. Technically, it still works, but you miss the total records and total pages data.

    Our recommendation is to avoid the 'custom response' whenever this is possible. The functionality is created to be able to mimic existing end points, not when you can still create new end points.

    Refresh the end point

Google Chrome

  1. 9. Disable custom response again

    Disable custom response again
  2. 10. To add dynamic limitations, add a parameter

    To add dynamic limitations, add a parameter
  3. 11. The parameter key is free to define. limit or page_size both make sense

    The type is integer

    The parameter key is free to define. limit or page_size both make sense
  4. 12. Select integer

    Select integer
  5. 13. Set a default value

    For the example with a dataset of 5 records, we choose 2. In real-worlds, you typically use higher figures.

    Set a default value
  6. 14. Add remarks and/or documantation

    It's a good practice to always document your work in-line the moment you create it

    Add remarks and/or documantation
  7. 15. Type here

    Type here
  8. 16. Save the parameter

    Save the parameter
  9. 17. Edit the REST data definition

    Edit the REST data definition
  10. 18. Set the parameter name at the default page size

    This is the name of your paramter, prefixed with a %

    Set the parameter name at the default page size
  11. 19. Press Alt + Tab

    Press Alt + Tab

Postman

  1. 20. Refresh and see how the default page size of 2 is handled

    Refresh and see how the default page size of 2 is handled
  2. 21. Change the limit in the parameter

    See the results, it affects your page size and works with the pagination

    Change the limit in the parameter