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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.