cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Syndicate_Admin
Administrator
Administrator

Handling 307–Temporary Redirect Errors With Web.Contents() In Power Query

I'm trying to pull data using Web.Contents() from a Web API and getting a 307-Temporary Re-direct.  

The URL I’m using works fine if I use Web.BrowserContents, but Web.BrowserContents only works with anonymous credentials. I’d rather use Web.Contents so that I can pass the ApiKeyName in the credentials.

 

I tried to use the option [ManualStatusHandling={307}] but get an "Expression.Error: ‘307’ is not supported by the ManualStatusHandling option."

 

Any ideas on how to handle the 307-Temporary Re-direct?

12 REPLIES 12
Syndicate_Admin
Administrator
Administrator

Hi @DarinSpence 

 

I've written about this topic here

 

Handling HTTP Errors in Power Query and Power BI • My Online Training Hub

 

regards

 

Phil

Syndicate_Admin
Administrator
Administrator

Hi @DarinSpence 

 

That's odd.  The MSOFT doco indicates that you can interept 3xx errors and handle them

 

Handling status codes with Web.Contents for Power Query connectors - Power Query | Microsoft Docs

 

But as you've found, you get an error with a 307.  In my testing I get an error with any of the 3xx status codes.  based on the doco, that's not what I expect.  Perhaps it is a bug?  You could report it.

 

I've tried in Excel and PBI and had the same errors.

 

Sorry, can't help any further at this point.

 

regards

 

Phil

Syndicate_Admin
Administrator
Administrator

Hi @DarinSpence 

 

Shouldn't the Web.Contents request just be redirected because of the 307?  So is there a need to use ManualStatushandling for a 307?

 

Regards

 

Phil

@PhilipTreacy , thanks for testing the 307.  I'll report it.  I suspect that there's come clever way to 'make it work,' but I'm struggling to find it.

Syndicate_Admin
Administrator
Administrator

Hi @DarinSpence 

 

I've written about manual handling of HTTP status codes but I only dealt with 4xx and 5xx

 

Handling HTTP Errors in Power Query and Power BI • My Online Training Hub

 

As the doco does seem to indicate that you can also manage 3xx, it's odd that it's generating this error.

 

Please post back here if you get an answer from Microsoft.

 

regards

 

Phil

Syndicate_Admin
Administrator
Administrator

Hello!
I am struggling with the same problem, trying to handle 302 redirects manually. Is there any update on this issue?

Thank you in advance!

Syndicate_Admin
Administrator
Administrator

Hello!
I am struggling with the same problem, trying to handle 302 redirects manually. Is there any update on this issue?

Thank you in advance!

All that I was told was that...

"By default, Web.Contents should follow up to 50 redirects before giving up and returning an error. Looking at the Fiddler traces, this seems to be what’s happening. However, it also seems like the site expects the “Set-Cookie” directives in the response to get passed on to the next request and they also told that kind of cookie-handling is only standard in browsers. (This could explain why the site works with Web.BrowserContents)."

Sadly, I don't know if there's anything that can be done.

Microsoft looked into this and said:  By default, Web.Contents should follow up to 50 redirects before giving up and returning an error. Looking at the Fiddler traces, this seems to be what’s happening. However, it also seems like the site expects the “Set-Cookie” directives in the response to get passed on to the next request and they also told that kind of cookie-handling is only standard in browsers. (This could explain why the site works with Web.BrowserContents.)

 

  • So, from product team response we can understand that only Web.BrowserContents works in this scenario.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (2,335)