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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
lexdekrijger
Frequent Visitor

API pagination last record is error

Edit: I cant just delete the bottom row, than it wont show me anything

 

Hello everyone, i have working code. Only the last record in the column with records i recieve is an error. I believe this to be because the the api is entirely loaded and the last row gives an empty record. So i get 218 rows in a column which i can expand with my data but the last row is an error row 219. I can do all my fixing in query editor but when i load it it says end of buffer reached. How do i fix this?

= let
CurrentPage = 0,
url = "*",
headers = [
#"Authorization" = "Bearer *,
#"Content-Type" = "application/json; charset=utf-8"
],
getDataForPage = (page) =>
let
response = Json.Document(Web.Contents(url & Text.From(page), [Headers=headers])),
data = response
in data,

Loop = List.Generate(
() => CurrentPage,
each List.Count(getDataForPage(_)) > 0,
each _ + 1,
each getDataForPage(_)
),

combinedData = Table.FromList(List.Combine(Loop), Splitter.SplitByNothing())

in
combinedData

1 REPLY 1
Anonymous
Not applicable

HI @lexdekrijger,

I'd like to suggest you add a condition after the "List.Count(getDataForPage(_)) > 0" to check if the current page has large or equal to the end page to skip the function calculate with wrong parameters.
Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.