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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
v-yuezhe-msft
Employee
Employee

@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

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks, I`ll check it out!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors