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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
RezaKorehi
Regular Visitor

Urgent - Paginated API - Loading Data

Have you ever used Paginated APIs in Power Query to import data? If you have, I have a challenge for you. One of my friends asked me this question, but I couldn’t help him. So, I’m reaching out to my network to find the answer.
He wants to add all the tasks based on each list id (lists.id). So, we need to send each list.id to the API to get the tasks.

  #"Added Custom Task" = Table.AddColumn(#"Removed Other Columns4" , "Custom", each Json.Document(Web.Contents("https://lnkd.in/gGDzdEbX"&[lists.id]&"/task?archived=false",[Headers=headers,Query = [archived = "false"]]))),
  #"Expanded Custom4" = Table.ExpandRecordColumn(#"Added Custom Task", "Custom", {"tasks", "last_page"}, {"tasks", "last_page"}),

However, some of the lists, like the first row, may have more than 100 tasks. So, their last_page value is FALSE.
He needs to add another row with the same data, but for the second, third... page for each list that has more than 100 tasks.
We tried a nested loop by using List.generate, but no luck.
Our other friend ChatGPT was not able to help either.
So I’m hoping my human network can help me with the answer1697540277080.jpg

1 REPLY 1
lbendlin
Super User
Super User

There are plenty of examples on the interwabs for paging through API resposes either via "next page"  links or with offset.  You can decide between List.Generate and List.Accumulate, depending on the expected amount of data  (but also keeping in mind that the browser cache will help).

 

As you can probably appreciate it is nearly impossible to help with API queries without access to said API  (which you may not be willing to provide for understandable reasons)

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors