Pardot API returns a next page token when number of items in response is bigger than the limit. I was looking for a way to iterate responses in a way that will use the new “next page token” on each loop iteration.
The solution: calculated delay, delay, retrieve token, api call, store token.
This is how i did it.
Before the loop:
- Run first iteration of api call and actions after.
- Store the refresh token in storage
The way i resolved it is by using delay, storage and some math.
- loop iteration through the max amount of iterations need, you can calculate it if you have access to the db.
- Calculate with formatter how much the delay should be (how much one request takes + a bit more). i had to slow it down to 5 iterations per minute.
- Retrieve the token stored
- At this point i added a filter to make sure i got the value and right after removed the value in order to make sure i don’t repeat the same iteration twice. this caused me to slow the delay to 4 per minute.
- Delay action by the part of the minute needed calculated in #2
- call api with the refresh token
- store the new refresh token
- Perform the actions you wanted to do with the data.
This should work, i ran into some max data retrieval limits but im able to control the date i want to start with so easy to run again.