Forum Discussion
gotmike
10 years agoFrequent Visitor
how to create a query that paginates?
I'm working with the Hubspot CRM API and when you query for a list of all deals, you only get 100 records at a time, and they want you to send subsequent queries with an "offset" to paginate the resu...
Anonymous
6 years agoNot applicable
ImkeF
After reading the thead I think this is what I need to fix my issue about the API pull we are trying to figure out for long time.
So basically we have an link given by vendor, and we can pull data.
The issue is its limited to 20,000 row per call.
I tried to use some of the codes from here and fail (still new to coding).
Here's what i have tried.
let
Pagination = List.Skip(List.Generate( () => [Last_Key = "init", Counter=0], // Start Value
each [Last_Key] <> null, // Condition under which the next execution will happen
each [ Last_Key = try if [Counter]<1 then "" else [WebCall][Value][offset] otherwise null,// determine the LastKey for the next execution
WebCall = try if [Counter]<1 then Json.Document(Web.Contents("Weblink+tokenkey"))
else Json.Document(Web.Contents("Weblink+tokenkey&offset="&Last_Key&"")), // retrieve results per call
Counter = [Counter]+1// internal counter
],
each [WebCall]
),1)
in
Pagination
JSON pull looks like this.