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. 6518bb2f2e0f9009462ec669481841f9?d=mm

    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. F5828b9070e646a4402d207a6db7856c?d=mm

    a5thKYC

    Apr 03, 2019 08:23

    Still happening in 2017.4.8f1. Please fix this

  3. Ad0ca85963c2e6dcd556cd5d6b63f35e?d=mm

    bugfinders

    Jan 16, 2019 16:13

    Still happening in 2018.3!

  4. Fb9585c99d4af990f890cef10224b8bc?d=mm

    Martin_Gonzalez

    May 03, 2018 15:12

    Still happening in 2017.4.1f1

  5. F01b99b9d8d87775dd8df16fa4db7339?d=mm

    nkillaars

    Apr 30, 2018 12:29

    Still happening on 2017.2.1p2 with a UnityWebRequest.Put

  6. 7a639b7eaa247418771e7f362639baab?d=mm

    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. 29dd83f2539ddf7f043b34f1e7d3a071?d=mm

    mario-m911

    Jun 14, 2017 03:46

    Still happening on 5.6.1f1

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.