Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

UnityWebRequest gives 403 "You don't have permission to access..." on one domain only

Discussion in 'Editor & General Support' started by Natrem, Sep 1, 2016.

  1. Natrem

    Natrem

    Joined:
    Feb 24, 2015
    Posts:
    31
    Hello,
    I wanted to use UnityWebRequest instead of WWW.
    However I got a problem that I didn't have with WWW. The following code always returns "403, isError is False" on a domain I own.
    Code (CSharp):
    1. UnityEngine.Experimental.Networking.UnityWebRequest webRequest = UnityEngine.Experimental.Networking.UnityWebRequest.Get("http://mydomain.thatdoesntwork.com/some_text.txt");
    2. webRequest.Send();
    3. while (!webRequest.isDone) ;
    4. Debug.Log(webRequest.responseCode + ", isError is " + webRequest.isError);
    I own another domain, so I tried putting there the same some_text.txt with the same permissions (644), and it works with that url: httq://myotherdomain.thatworks.org/some_text.txt
    I can access both addresses in a browser from the same computer, even in Private mode. The domain that works has a .htaccess, for unrelated redirection; the broken one doesn't.
    The 403 message with isError is False is always there, no matter what I put after httq://mydomain.thatdoesntwork.com, an existing file or not. And obviously webRequest.downloadHandler.text contains the 403 standard page HTML code. With the other domain, I get the correct behavior everytime.

    What can I try next?
    Thank you if you can help me.

    PS: I put httq on purpose to disable links.
     
  2. Natrem

    Natrem

    Joined:
    Feb 24, 2015
    Posts:
    31
    By the way, I tested this with Unity 5.3.5f1, do you think it's fixed in 5.4? I didn't see anything concerning this problem in release notes or in the issue tracker.
     
  3. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Use Fiddler and see what the payload is that's being sent to the server and what the response is. I don't think this is probably a Unity bug because 403 is being returned by the server. It's possible that you're passing an Authorization header with incorrect information in it, resulting in a 403.... it's hard to tell.