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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Auke
Frequent Visitor

How to build in a delay to avoid api request limit

 

I`m currently experiencing issues with the request limit of an api. Below is my code. I've been trying to use 

Function.InvokeAfter(Pagination, #duration(0,0,0,2)

But I can't get it to work. Any suggestions on how to implement this in here:

 

Thanks 🙂

 

let
Pagination = List.Skip(List.Generate( () => [WebCall=[], Page = 1, Counter=0], // Start Value
   		each List.Count(Record.FieldNames([WebCall]))>0 or [Counter]=0, // Condition under which the next execution will happen
   		each [ WebCall = Json.Document(Web.Contents("https://api.rechargeapps.com/customers/?page="&Text.From([Page])&"", [Headers=[#"x-recharge-access-token"="APIKEY"]])), // retrieve results per call
     		Page = [Page]+1,
     		Counter = [Counter]+1// internal counter     			
]
) ,1),
    #"Converted to Table" = Table.FromList(Pagination, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"WebCall"}, {"Column1.WebCall"}),
    #"Expanded Column1.WebCall" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1.WebCall", {"customers"}, {"Column1.WebCall.customers"}),
    #"Expanded Column1.WebCall.customers" = Table.ExpandListColumn(#"Expanded Column1.WebCall", "Column1.WebCall.customers"),
    #"Expanded Column1.WebCall.customers1" = Table.ExpandRecordColumn(#"Expanded Column1.WebCall.customers", "Column1.WebCall.customers", {"id", "shopify_customer_id", "created_at", "updated_at", "status"}, {"Column1.WebCall.customers.id", "Column1.WebCall.customers.shopify_customer_id", "Column1.WebCall.customers.created_at", "Column1.WebCall.customers.updated_at", "Column1.WebCall.customers.status"})
in
    #"Expanded Column1.WebCall.customers1"

 

2 REPLIES 2
Anonymous
Not applicable

@Auke,

Do you add Function.InvokeAfter(Pagination, #duration(0,0,0,2) into #"Converted to Table" line in your code?

I would recommend you use Ken's  code or Chris's code in this similar thread and check if it works as expected.

Regards,
Lydia

Thanks, I`ll check it out!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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