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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. 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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.