I have been using the following tutorials to pull all paginated records from a Web API.
(Page as number) => let Source = Json.Document(Web.Contents("https://churchmetrics.com/api/v1/records.json?page=" & Number.ToText(Page) & "&per_page=100" , [Headers=[#"X-Auth-User"="xxxxxxxxxxxxxxxxxx", #"X-Auth-Key"="xxxxxxxxxxxxxxxx"]])) in Source
This invokes fine with page 1 (data) and returns records, and page 4 (no data) returns list with no rows.
Query to pull all pages together:
= List.Generate( ()=> [Result= try GetData(1) otherwise null, Page = 1], each [Result] <> null, each [Result = try GetData([Page]+1) otherwise null, Page =[Page]+1], each [Result])
Now when I refresh thi,s it takes a long time, but then produces - what seems like infinate lists (over 1,000). As tested in the function lists over 3 are empty. The tutorials I used used the query to, basciallly, if error then null, if null then stop. But the issue I am facing is that the query doesn't throw up an error it just provides a blank list. This seems like an easy fix but I cant figure it out.
All help would be apreciated.
Thanks in advance.
For any concern about the used M function in the tutorial, you could add comments and ask questions at the bottom, I think the author should be more familar with it and give you advice.