Forum Discussion
felipe_pinto
4 years agoHelper I
Error 429 too many request on Power Query
Hello Guys, I'm haveing troubles to end the follwing code. I need to find a solution to error 429...the API has a limit of 15 request per minute...could someone help me? Code: = (CNPJ as nu...
v-yingjl
4 years agoCommunity Support
Hi felipe_pinto ,
As the article mentioned, need to add Value.Waitfor() definition in the query, after combining with your code, the final query could be like this:
(CNPJ as number) =>
let
Value.WaitFor = (producer as function, interval as function, optional count as number) as any =>
let
list = List.Generate(
() => {0, null},
(state) => state{0} <> null and (count = null or state{0} < count),
(state) => if state{1} <> null then {null, state{1}} else {1 + state{0}, Function.InvokeAfter(() => producer(state{0}), interval(state{0}))},
(state) => state{1})
in
List.Last(list),
Result = Value.WaitFor(
(iteration) =>
let
content = Web.Contents("URL" &Text.PadStart(Number.ToText(CNPJ),14,"0")& "&plugin=RF", [ManualStatusHandling = {429}]),
buffered = Binary.Buffer(content),
status = Value.Metadata(content)[Response.Status],
actualResult = if status = 429 then null
else Json.Document(Text.FromBinary(buffered))
in
actualResult,
(iteration) => #duration(0, 0, 1, 0),
10
)
in
Result
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
felipe_pinto
4 years agoHelper I
Hello v-yingjl , how are you doing?
Thank you so much for your help and your time.
I got the combination you did, I'll try that and see if it's gonna work 🙂
Thank you so much one more time!!