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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
DarinSpence
Helper I
Helper I

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?

9 REPLIES 9
daviddusa
Regular Visitor

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.

PhilipTreacy
Super User
Super User

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



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

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



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

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



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


@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.

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.

Thank you for going after the issue!

Unfortunately, Web.BrowserContents is not applicable for in case, because headers cannot be provided for the method. I am trying to solve basic authentication using the Authorization header.

The only workaround I see currently is to modify our REST API slightly.

Sadly, I cannot modify the API.  I'd rather use Web.Contents, but it doesn't look like that will be supported.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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
Top Kudoed Authors