Forum Discussion

tempranello's avatar
tempranello
Advocate I
10 years ago
Solved

how to create a query that paginates?

Hello there

 

I've a Dovico web API that I need to access to pull down all records.  For clarity, I'm calling the Time Entries function.

 

The API lists request restritcions as:

 

...limited to 5 calls per second and 1000 results returned per call. This means 5000 records per second are returned for GET calls...When the page results are returned they will include the Previous Page URI and Next Page URI. If the Next Page URI returns the value of “N/A” then that’s the last page

 

When I use the following Web.Contents call (tokens obscured for security) I get a neat result set of 1,000 rows:

 

= Web.Contents("https://api.dovico.com/TimeEntries/?version=5",[Headers=[#"Authorization"="WRAP access_token=""client=XXX&user_token=YYY"""]])

 

In other words I'm sending only one request.  If I run = Xml.Tables(<source above>,null,1252) I can clearly see both PrevPageURI and a NextPageURI data.

 

I've spent a huge amount of time googling my heart out, and trying all sorts of things, but thus far I'm a numpty.

 

Has anyone advice for me on how I can exploit the NextPageURI returned by the query to then repeat the query until I hit N/A?

 

I appreciate your support!

14 Replies