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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Bastian
New Member

Generating a list from a REST response with pagination

Hi Experts,

beeing new to Power Query I am trying to access the pages of a REST response and transform those to one single list by using List.Generate.

Unfortunately I don't receive the full list. Instead the produced list contains only one Element "Error" which only contains the result of the first page. Any Ideas?

 

(The API documetation can be found here: https://apidocs.tempo.io/#worklogs )

 

My code is as follows:

 

From="2021-08-01",
To="2021-08-31",
tempoURL= "https://api.tempo.io",
tempoPath = "/core/3/worklogs",
tempoQuery = "?from=" &From& "&to=" &To& "&limit=10",

Token="XXXXX",

finalResult=List.Generate( ()=> 
    [
        URL = tempoURL&tempoPath&tempoQuery,
        Result = Json.Document(Web.Contents(URL, [Headers=[Authorization="Bearer " & Token]]))
    ],
    each [URL] <> null,
    each [
        URL = [Result][metadata][next],
        Result = Json.Document(Web.Contents(URL,[Headers=[Authorization="Bearer " & Token]]))
    ]
)
in
    finalResult

 

 

Which produces the following:

 

Bastian_2-1635285986402.png

Bastian_3-1635286011307.png

Bastian_4-1635286033781.png

Bastian_5-1635286086005.png

Bastian_6-1635286146607.png

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Since your "next" URL is well structured with Offset and Limit  you could choose to fetch the total rowcount in your first call and the use List.Generate to create all the urls  (and maybe up the limit a bit so you don't have to fetch in groups of 10). Then it would be a simple Table.AddColumn with the Web.Contents of the generated URLs.

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

Since your "next" URL is well structured with Offset and Limit  you could choose to fetch the total rowcount in your first call and the use List.Generate to create all the urls  (and maybe up the limit a bit so you don't have to fetch in groups of 10). Then it would be a simple Table.AddColumn with the Web.Contents of the generated URLs.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon โ€“ Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save โ‚ฌ200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors