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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors