Hello,
Anyone solved pagination in postman?
What problem does postman has with pagination?
Hey,
Example, if you run - organizations/:organizationId/networks
It gives you 1000 networks and I haven't found any way to handle the next pages with 1000 more.
in python its no problem - but just dont know how to activate it or fix it in postman
In the response headers, you will find a "link" field specifying the links to the first, last, next, and previous "pages".
Yes, i understand this - but is it possible to load the rest inside the postman call so the list will be complete?
I have a pagination solution 🙂
There is not really an easy way to do this with Postman natively, but I created a script you can add to your Collection "Tests". It will perform some magic on every API request by extracting the link string in the header.
I posted a copy of the script in my github for now.
https://github.com/dexterlabora/Meraki-Dashboard-API-Postman-Collection/blob/master/tests/pagination...
Example showing the usage with {{endingBefore}} environment variable via this script
This script is designed to handle pagination in APIs by extracting the necessary information from the Link header of the HTTP response. It then sets the startingAfter and endingBefore environment variables in Postman which can be used as query parameters for subsequent API calls to navigate through paginated data.
The script primarily consists of a function parseLinkHeader that processes the Link header from the HTTP response, and a main block that checks for the presence of the Link header, extracts the pagination links, and sets the environment variables.
Let me know if this works for you. If it this seems like a doable solution, we could possibly add it to the Meraki collection by default.
That seems to work like a charm, just tested it on getOrganizationNetworks
It gets the last networkID of the 1000 networks, and set the startingAfter to the ID L_xxxxxxxxxxxx107400
Ending before is set to the FIRST network of the second call, is that correct? (Didnt use endingBefore)
Very good work! Thx