Search Issue Tracker

Fixed in 5.5.1

Votes

0

Found in

5.3.6p7

Issue ID

851921

Regression

No

UnityWebRequest POST with empty body results in Error

Networking

-

Steps to reproduce:
1. Open User's attached project
2. Press Play

Result: calling UnityWebRequest.Post() method results wit Error in the Console: ArgumentException: Cannot create a data handler without payload data.

Reproduced with: 5.6.0a3, 5.5.0b11, 5.4.2p4, 5.3.7p1

Note: reproduced on both Mac and Windows.

Comments (7)

  1. Rafael_CS

    Jul 12, 2019 02:09

    Hello guys,
    replace your PUT request to this code to fix the bug.

    public static UnityWebRequest Put(string uri, byte[] bodyData)
    {
    return new UnityWebRequest(uri, "PUT", (DownloadHandler) new DownloadHandlerBuffer(), bodyData == null || bodyData.Length == 0? null : (UploadHandler) new UploadHandlerRaw(bodyData));
    }

  2. a5thKYC

    Apr 03, 2019 08:23

    Still happening in 2017.4.8f1. Please fix this

  3. bugfinders

    Jan 16, 2019 16:13

    Still happening in 2018.3!

  4. Martin_Gonzalez

    May 03, 2018 15:12

    Still happening in 2017.4.1f1

  5. nkillaars

    Apr 30, 2018 12:29

    Still happening on 2017.2.1p2 with a UnityWebRequest.Put

  6. LiveOrDevTrying

    Jan 30, 2018 14:56

    Use the following code:

    protected virtual IEnumerator PostEmptyBody(string route)
    {
    var headers = new Dictionary<string, string>
    {
    { "Content-Type", "application/json" }
    };

    var packetToSend = JsonUtility.ToJson(string.Empty);

    var body = Encoding.UTF8.GetBytes(packetToSend);

    var www = new WWW(route, body, headers);

    yield return www;

    if (!string.IsNullOrEmpty(www.error))
    {
    Debug.Log(www.error);
    }
    }

    Cheers,

  7. mario-m911

    Jun 14, 2017 03:46

    Still happening on 5.6.1f1

Add comment

Log in to post comment