Search Issue Tracker

Fixed in 2017.3.0f3

Votes

2

Found in

2017.3.0b5

Issue ID

960676

Regression

Yes

[Networking] UnityWebRequest.Post returns "Generic/unknown HTTP error"

Networking

-

Steps to reproduce:
1. Open attached project
2. Play the scene
3. Notice the WebRequest Error: Generic/unknown HTTP error

Expected result: console should print: Return data: post field is set instead

Reproduced in: 2018.1.0a1, 2017.3.0b5, 2017.3.0b1
Not reproduced in: 2017.3.0a7, 2017.2.0f3
Regression since: 2017.3.0b1

Comments (34)

  1. Baalair

    Oct 05, 2018 22:39

    I was experiencing this issue with 20182.2f1. The work around for the Post method shown here fixed it for me:

    https://codetolight.wordpress.com/2017/01/18/unity-rest-api-interaction-with-unitywebrequest-and-besthttp/

    Just remember to add an Access Token to the request header if you need to.

  2. guneyozsan

    Sep 20, 2018 03:09

    I still get this on 2018.2.6f1. Setting chunk false does not do any good. Any workarounds?

  3. mustafaneguib88

    May 07, 2018 19:03

    I am using Unity3d 2017.4.2f2 and I am getting this error as well.
    Following is my HTTP POST request:

    List<IMultipartFormSection> formData = new List<IMultipartFormSection>();
    formData.Add(new MultipartFormDataSection("email="+email+"&amp;name="+name));
    UnityWebRequest www = UnityWebRequest.Post(Utility.BASE_URL + Utility.LOGIN, formData);
    www.chunkedTransfer = false;
    yield return www.SendWebRequest();

    if (www.isNetworkError || www.isHttpError)
    {
    Debug.Log(www.error);
    }
    else
    {
    Debug.Log(www.downloadHandler.text);

    }

  4. citron8000

    May 07, 2018 12:08

    This is not fixed in 2017..3.1p4 either. I tried all workarounds in this thread with no luck. I get a Generic/unknown HTTP error while it's works with Postman.

  5. citron8000

    May 07, 2018 11:54

    This is not fixed in 2017..3.1p2

  6. PXtreme

    Apr 27, 2018 06:54

    I use UnityWebRequest and I am on 2017.4.0f1, and I have tried all work arounds from different forums. From changing chunkedTransfer to false, Using Put, but changing the method to "POST", Adding .SetRequestHeader ("X-HTTP-Method-Override", method), trying uploadhandler and downloadhandler. I tried sending raw JSON on Postman and the request was received but in Unity, it just gives me "Generic/unknown HTTP error". Please help.

  7. baumerj

    Apr 25, 2018 20:22

    Figured this out and it works now! Version 2017.3.1f1. Here's the code:

    string accessUri = "";
    string data1 = "";
    string data2 = "";

    WWWForm form = new WWWForm();
    form.AddField("data1", data1);
    form.AddField("data2", data2);

    using (UnityWebRequest www = UnityWebRequest.Post(accessUri, form)) {
    yield return www.SendWebRequest();

    if (www.isNetworkError || www.isHttpError) {
    Debug.Log(www.error);
    } else {
    Debug.Log("Form upload complete!");
    }
    }

  8. baumerj

    Apr 25, 2018 15:18

    @ARESUNDNES - Can you post your code as an example? I tried www.chunkedTransfer = false; and am still getting the error.

  9. aresundnes

    Apr 24, 2018 10:29

    The issue is resolved for me by setting chunkedTransfer to false:

    ```
    UnityWebRequest www = UnityWebRequest.Post(url, formData);
    www.chunkedTransfer = false;
    ```

  10. Steamc0re

    Apr 11, 2018 23:37

    Not fixed. Still get in 2017.4.0f1

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.