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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Leggies
Frequent Visitor

Trying to make a loop to get all API data (Pagination)

Hi,
I succeed to get some data in Power Query though api call, but not get all data.

Leggies_0-1629894250856.png



Now I'm trying to create a loop to get all the API data from Zendesk, but its not working. I get the error "We cannot convert a value of type List to type Number." This is the Query:

let
Page = {1,1000},
Source = Json.Document(Web.Contents("https://xxxxxxx.zendesk.com/api/v2/tickets.json?page="&Number.ToText(Page), [Headers=[Authorization="Basic ZGlxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]])),
#"Converted to Table" = Table.FromRecords({Source}),

List = List.Generate(() =>
[Result= try GetData(1) otherwise null, Page = 1],
each [Result] <> null,
each [Result = try GetData([Page]+1) otherwise null, Page =[Page]+1],
each [Result])

in
#"Converted to Table"

Can somebody tell me what is wrong with the code i'm using? I tried a lot of methods, but with no success.

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Leggies ,

 

Please create a new table with all page values and then refer to this blog to use column as parameter to return all needed values:

Use Column as Parameter for Custom Function in Pow... - Microsoft Power BI Community.

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Icey
Community Support
Community Support

Hi @Leggies ,

 

Please create a new table with all page values and then refer to this blog to use column as parameter to return all needed values:

Use Column as Parameter for Custom Function in Pow... - Microsoft Power BI Community.

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Leggies , For relative path, refer try this

https://blog.crossjoin.co.uk/2016/08/16/using-the-relativepath-and-query-options-with-web-contents-i...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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