cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DSArkphire Frequent Visitor
Frequent Visitor

Web-based Cursor-Based Pagination issues

Hi I’ve been working on trying to use List.generate to create a paginated list from a api. My issue is that my api uses Cursor-Based Pagination. A single request will give me three sections “has-more” “offset” and “companies”.

2.png

If "has-more" is true, I need to make another request, using the "offset" value given to get the next page of company records, "companies" is the actual information I need.

 

3.png

 

I cant seem to figure out how to refer to the “has-more” and “offset” values within the list.generate step. No matter what I try list generate returns null values. 

 

4.png

 

5.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Web-based Cursor-Based Pagination issues

Hi @DSArkphire 

you're not using the correct syntax to reference objects in Power Query / the M-language.

Try this:

 

Pagination = List.Generate( ()=>
	 Source, // Start value should be a record
	each [offset] <> 0 //  refers to the records field (your expression would always return true)
	each Json.Document(Web.Contents(<YourURLin””> & Text.From([offset])
)

Further reading on value types and how to reference them: https://docs.microsoft.com/en-us/powerquery-m/expressions-values-and-let-expression 

 

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




2 REPLIES 2
Super User
Super User

Re: Web-based Cursor-Based Pagination issues

Hi @DSArkphire 

you're not using the correct syntax to reference objects in Power Query / the M-language.

Try this:

 

Pagination = List.Generate( ()=>
	 Source, // Start value should be a record
	each [offset] <> 0 //  refers to the records field (your expression would always return true)
	each Json.Document(Web.Contents(<YourURLin””> & Text.From([offset])
)

Further reading on value types and how to reference them: https://docs.microsoft.com/en-us/powerquery-m/expressions-values-and-let-expression 

 

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




DSArkphire Frequent Visitor
Frequent Visitor

Re: Web-based Cursor-Based Pagination issues

Thank you for your Help ImkeF and for explaining my problem, that's a big help. 

Helpful resources

Announcements
Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 315 members 3,581 guests
Please welcome our newest community members: