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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Saadii_360o
Helper I
Helper I

Rest API Pagination Query (List. Generate)

HI . sorrry for posting this second or third time but could'nt find any solutions from the community. let me know if some who can help me out. Any power query expert here with Rest API's who can help me with List. Generate function query for pagination?
Issue: Pagination of API URL that allows 50 rows of data per Agent.
URL: https://vcc-na4.8x8.com/api/stats/agents/{Agent-ID}/Activities?n=1
Background: Created a function below which allows me to extract all Agent ID's(But only 50 rows per ID).
(id as text, n as number) as table=>

let

Source = Xml.Tables(Web.Contents("https://vcc-na8.8x8.com",

[RelativePath="/api/stats/agents/" &(id)&"/activities?n="&number.totext(n) ) ),

in
Source

Than a created a query below to extract all the rows as well watching curbal's video,
Video Link: https://www.youtube.com/watch?v=05yhwnuCjRw
Query:
let
Source = List.Generate(()=>
[result = try all_rows (1) otherwise try null, n=1],
each [result]<> null,
each [result = try all_rows ([n]+50) otherwise null, n=[n]+50],
each [result]

)
in
Source
but it shows this error,

Saadii_360o_0-1646507639671.png
Let me know if someone can solve my issue.
I am available for skype or zoom call anytime.if someone wants to understand the issue or resolve m,y issue that would be a huge help.

2 REPLIES 2
V-lianl-msft
Community Support
Community Support

Hi @Saadii_360o ,


There seems to be no problem with PQ expression, but can't you get the content of the table?

I checked your website, which requires login.

Have you try connecting to REST APIs With OAuth2 Authentication In Power Query?

https://blog.crossjoin.co.uk/2021/08/29/connecting-to-rest-apis-with-oauth2-authentication-in-power-... 

 

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

Yes. I am unable to retrieve data by this query. but i have created two other queries which allows me to extract data but like all the rows. and one query which allows to extract all the id's.

PFB the video link to see what i want,
https://drive.google.com/file/d/1swxDQTqDQ9ASIj76CMNMhgWWCiDDw47d/view?usp=sharing

Best,
Saad.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.