• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Kupper · Aug 04, 2017 at 09:50 AM · networkingnetworkwwwphpwwwform

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 :)

 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;
         }
 }

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image VBarreto87 · Aug 28, 2017 at 04:21 AM 0
Share

Still no fixes for it?

avatar image plasticYoda VBarreto87 · Dec 13, 2017 at 01:00 AM 0
Share

I don't think it's a bug - I think it's intentional - you need to set the headers before you use it.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by plasticYoda · Dec 12, 2017 at 09:36 PM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image KenyAguilar · Mar 07, 2018 at 09:42 PM 0
Share

this worked flawlessly! thank you. I had to do WWW www = new WWW(url, form.data, ht);

avatar image
1

Answer by Aelcyx · Sep 30, 2017 at 05:43 PM

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kupper · Sep 30, 2017 at 05:56 PM 1
Share

Thank you for the answer, I will try it out and let you know if it works for us as well :)

avatar image Aelcyx Kupper · Oct 05, 2017 at 09:26 PM 0
Share

You're welcome! I hope it works. Please mark the answer as accepted if so.

avatar image richardhaddadau · Nov 06, 2017 at 10:23 AM 0
Share

@Aelcyx, thanks for your answer; although it works, I still wonder why it's even needed. I mean, what's causing it? It seems like this only started occurring with Unity 2017.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

117 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Retrieving varibale values from a php script? 1 Answer

WWWForm.Addfield not able to post data to server 1 Answer

Disable execute/write permissions on PHP files while maintaining the ability to execute them from Unity? 1 Answer

WWWForm problem 1 Answer

wwwform send an array the right way! 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges