09-26-2023 01:39 PM
09-26-2023 10:17 PM
What problem does postman has with pagination?
09-27-2023 12:02 AM
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
09-27-2023 06:24 AM
In the response headers, you will find a "link" field specifying the links to the first, last, next, and previous "pages".
10-01-2023 11:15 AM
Yes, i understand this - but is it possible to load the rest inside the postman call so the list will be complete?
10-03-2023 06:24 AM
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.js
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.Example of script in the Tests section
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.
10-03-2023 07:28 AM
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
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide