Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
DesignerMat
New Member

Web API Pagination issue

Hi There,

 

I have been using the following tutorials to pull all paginated records from a Web API.

 

Blog: https://www.mattmasson.com/2014/11/iterating-over-an-unknown-number-of-pages-in-power-query/

Video: https://www.youtube.com/watch?v=vhr4w5G8bRA&t=6s

 

My code:

 

GetData Function:

(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.

1 REPLY 1
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @DesignerMat,

 

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.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.