After updating to v2017.1, a www call returns "406 not acceptable"

Hi all

We used to use v5.6.1f where everything worked great. But after updating to v2017.1, the www call, is being rejected by the server with a “406 Not Acceptable” error.

We have tried to remove the security filter from the webserver thrugh the .htaccess file (even though this is not good manner). This removed the “406 Not Acceptable” error, but still no response was collected from the webserver.

Anyone who has an idea on what could be wrong? Do we need to add a header when doing the call to the web server? If so, how can we do that?

It must be mentioned, that no changes has been made to the webserver or the
PHP script which is being called from
the www!

Here is the code sample, which used to work in the previous version of Unity :slight_smile:

IEnumerator LoadUserInfoRoutine() {
        WWWForm form = new WWWForm ();
		form.AddField ("unity_security", mySecurityCode);
		form.AddField ("unity_method", "connect");

		WWW www = new WWW(myURL, form);
		yield return www;

		if(www.error != null) {
			Debug.Log (www.error);
		} else {
			response = www.text;
        }
}

Still no fixes for it?

I found that adding these headers made it work:

    headers.Add("Accept", "*/*");
    headers.Add("Accept-Encoding", "gzip, deflate");
    headers.Add("User-Agent", "runscope/0.1");

I figured this out by going to hurl.it, trying the request there and then looking at the response data via browser tools.

I was using plain old www, and had the same problem. However, I needed to continue to use GET and not POST. To fix the error I used the following code to add the headers to the GET request.

    Dictionary<string, string> ht = new Dictionary<string, string>();
    ht["Accept"] = "*/*";
    ht["Accept-Encoding"] = "gzip, deflate";
    ht["User-Agent"] = "runscope/0.1";
    WWW www = new WWW(url, null, ht);
    yield return www;

Now the code works as it used to. @richardhaddadau - pretty sure the Unity guys changed stuff under the hood so the engine on PC/Mac no longer sets the headers to default values. The code still worked as expected on iOS/Android for me.