Forum Discussion

DarinSpence's avatar
DarinSpence
Helper II
4 years ago

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

  • 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

    • DarinSpence's avatar
      DarinSpence
      Helper II

      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.

      • DarinSpence's avatar
        DarinSpence
        Helper II

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

  • daviddusa's avatar
    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!

    • DarinSpence's avatar
      DarinSpence
      Helper II

      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.