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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
kunal1120
New Member

List.Generate function returning the same value while calling a rest API which supports cursor

Hi, I am trying to get data from a rest API which sends the cusor information for the next page. I am geeting the same cursor back as It keeps on triggering the initial condition in List. Gernate

 

My code 

 

let
    FnGetOnePage =  (cursor_ as text) => Json.Document(Web.Contents(URLEndPoint,[
            Headers = [#"Content-Type"="application/json", #"Authorization"=token],
            Content = Text.ToBinary("{""kind"": """ & kind & """,""limit"": """ & Number.ToText(100) & """, ""cursor"": """ & cursor_ & """}")
            ]))

GeneratedList = List.Generate(
                       ()=> [res = FnGetOnePage("")],
                           each [res][cursor]<>null,
                           each [res = FnGetOnePage([res][cursor])]                                                              
                       ) 
in 
      x
1 REPLY 1
Anonymous
Not applicable

Hi @kunal1120 ,

 

You may kindly refer to

Part 2: Programming "Do-Loop" loops with List-Generate() in M for Power Query - data-insights.de: Mi...

List.Generate in Power Query: Tutorial with Easy Examples

 

 

Best Regards,

Stephen Tao

 

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

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.