Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Changed behavior of WWW class (POST vs GET)

Discussion in '2017.1 Beta' started by stephencoorey, Apr 20, 2017.

  1. stephencoorey

    stephencoorey

    Joined:
    Mar 29, 2017
    Posts:
    10
    Previously (as recently as Unity 5.6), it was possible to add header data to a WWW GET request by passing null in as the postdata parameter like this:

    string URL = "https://somewhere.com/LookupREST/2.0?foo=234asdfas090&countrycode=US";
    Dictionary<string, string> headerInfo = new Dictionary<string, string>();
    headerInfo.Add("Authorization", "Basic AFDS90AFDS908FDS987F86HG876");
    WWW www = new WWW(URL, null, headerInfo);
    yield return www;

    Documentation says: "The WWW class can be used to send both GET and POST requests to the server. The WWW class will use GET by default and POST if you supply a postData parameter."

    This seems to have changed in the 2017 beta, and has broken the way we enforce GET to be used with headers. Is there any chance this will be switched back on the next beta build?
    Is there another way to do this? I read that System.Web only works on Windows machines, we want a cross platform solution.

    I have submitted an official bug report using the beta's Help->Report a bug feature.

    More info here: https://forum.unity3d.com/threads/get-method-with-header-in-www-class-unity.88853/#post-2971868
     
    Last edited: Apr 20, 2017
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    Thanks for notifying. This is indeed a regression and I'll do my best to fix it ASAP.

    Yes, you can use UnityWebRequest for this.
     
    stephencoorey and elbows like this.