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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Antesamegutt
Frequent Visitor

Web.Contents GET API call -- retry if 502 bad gateway

Hi!

 

I have a table of GET API URLs in a query which I call with a Web.Contents in a separate function query. 

 

My table query refreshes often crash due to one of the function calls returning a 502 bad gateway. 

 

Is it possible to add some code to force my Web.Contents to retry if 502 BG is returned? Is this ill adviced? The refresh will typically work when I try to refresh it again, or crash on another URL 

 

 

(URL) as table =>

let
Source = Json.Document(Web.Contents(URL)),

/* Somehow retry if Source returns 502 */

in

Source

 

Thanks! 

 

 

 

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Yes. There are a couple nice blog articles about that - for example Handling Unsuccessful HTTP Requests in Power Query M (tonymcgovern.com) 

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

I am actually abusing try...otherwise... as a cheap way to have a second attempt at an API call if the first one fails (some APIs need "warm up calls").  Not generally recommended, but neat when it works.

lbendlin
Super User
Super User

Yes. There are a couple nice blog articles about that - for example Handling Unsuccessful HTTP Requests in Power Query M (tonymcgovern.com) 

Thanks!

 

If it should help anyone in the future, try 'try'

 

https://docs.microsoft.com/en-us/power-query/handlingerrors

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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