Forum Discussion
Anonymous
4 years agoNot applicable
Rest API - call the next page URL without knowing total rows or total pages
Hi Everyone, This is my first time working with a REST API in Power BI and I'm running into an issue with pagination... I have an initial GET that calls out to a REST service which returns 1...
- 4 years ago
Hi Anonymous
The next page url is stored in Result[_pagination][next] so try this
let Source = List.Generate( () => [ URL = "https://api2.frontapp.com/" , Result = Json.Document(Web.Contents(URL)) ], each [URL] <> null, each [ URL = [Result][_pagination][next] , Result = Json.Document(Web.Contents([URL])) ] ) in SourceThis code will end assuming that [_pagination][next] is null when there are no more records to retrieve.
Regards
Phil
PhilipTreacy
Super User
4 years agoHi Anonymous
The next page url is stored in Result[_pagination][next] so try this
let
Source = List.Generate( () =>
[ URL = "https://api2.frontapp.com/" , Result = Json.Document(Web.Contents(URL)) ],
each [URL] <> null,
each [ URL = [Result][_pagination][next] , Result = Json.Document(Web.Contents([URL])) ]
)
in
Source
This code will end assuming that [_pagination][next] is null when there are no more records to retrieve.
Regards
Phil
Anonymous
4 years agoNot applicable
Thank you Philip! That [_pagination][next] was the piece I was missing!