Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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...
  • PhilipTreacy's avatar
    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
        Source

     

     

    This code will end assuming that [_pagination][next] is null when there are no more records to retrieve.

     

    Regards

     

    Phil