• 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
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 everyt$$anonymous$$ng 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 t$$anonymous$$s is not good manner). T$$anonymous$$s 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 w$$anonymous$$ch is being called from the www!

Here is the code sample, w$$anonymous$$ch 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
Aelcyx

People who like this

1 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
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
KenyAguilar

People who like this

1 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

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 t$$anonymous$$s out by going to hurl.it, trying the request there and then looking at the response data via browser tools.

Comment
richardhaddadau

People who like this

1 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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

wwwform send an array the right way! 0 Answers

Would a WWW to a PHP file return the computers Info? 0 Answers

WWW with https resulting in SSL: couldn't create a context 0 Answers

PHP POST through $_REQUEST with WEBBUILD 1 Answer

Problem using WWW with PHP and MYSQL 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges