Forum Discussion
Zenly
3 years agoRegular Visitor
Web API Query Issue
Hi, This is my first post on this forum. My name is Carl. 🙂 I wish to import the XML table https://boardgamegeek.com/xmlapi2/collection?username=Zenly&excludesubtype=boardgameexpansion into...
Anonymous
3 years agoNot applicable
Hi Zenly - you should consider Using the wait-retry pattern in Power Query connectors - Power Query | Microsoft Learn.
Zenly
3 years agoRegular Visitor
Hi Anonymous: Thank you for your reply. My coding and syntax skills are very limited. How would the code for https://boardgamegeek.com/xmlapi2/collection?username=Zenly&stats=1 with wait-retry pattern look like?
let
Source = Xml.Tables(Web.Contents("https://boardgamegeek.com/xmlapi2/collection?username=Zenly&stats=1")),
waitForResult = Value.WaitFor(
(iteration) =>
let
result = Web.Contents(url, [ManualStatusHandling = {500}, IsRetry = iteration > 0]),
status = Value.Metadata(result)[Response.Status],
actualResult = if status = 500 then null else result
in
actualResult,
(iteration) => #duration(0, 0, 0, Number.Power(2, iteration)),
5)
in
if waitForResult = null then
error "Value.WaitFor() Failed after multiple retry attempts"
else
waitForResult