Forum Discussion
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
- AnonymousNot 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