Quantcast
Channel: Power Query topics
Viewing all articles
Browse latest Browse all 31002

How to build in a delay to avoid api request limit

$
0
0

 

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 Smiley Happy

 

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"

 


Viewing all articles
Browse latest Browse all 31002

Trending Articles