Search Unity

Post requests doesn't work in 2017.3

Discussion in 'Scripting' started by Qvist, Dec 27, 2017.

  1. Qvist

    Qvist

    Joined:
    Dec 2, 2010
    Posts:
    76
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,335
    To get bugs looked at, you need to post a bug report with a repro case. Forum posts are not neccessarilly read by Unity staff.
     
  3. Qvist

    Qvist

    Joined:
    Dec 2, 2010
    Posts:
    76
    Yeah, I just took the chance here, since the bug report I was linking to in the first post is exactly the same issue. No need to have duplicates.
    But I'll create one, if I don't get any response here. ;)
     
  4. avorobjev

    avorobjev

    Joined:
    Apr 3, 2014
    Posts:
    8
    Same issue in Unity 2017.3.0f3 - WWW post not works (it works in POSTMAN but not in Unity)
    I changed my methods from WWW to UnityWebRequest like this:
    Code (CSharp):
    1. IEnumerator Post()
    2.      {
    3.                 string postData = "{....post data json...}";
    4.                 byte[] bytes = GetBytes(postData);
    5.                 using (UnityWebRequest www = UnityWebRequest.Put("http://localhost/api/PutMethod", rawData))
    6.                 {
    7.                     www.SetRequestHeader("Content-Type", "application/json");
    8.                     www.SetRequestHeader ("Accept", "text/json");
    9.  
    10.                     yield return www.Send();
    11.  
    12.                     if (www.isNetworkError)
    13.                     {
    14.                         Debug.Log(www.error);
    15.                     }
    16.                     else
    17.                     {
    18.                         Debug.Log(www.downloadHandler.text);
    19.                     }
    20.                 }
    21.         }
    But I had to change from POST to PUT and it works
     
    Last edited: Jan 23, 2018