Skip to content

In multipart form, JSON part is missing the JSON content type in the content disposition header #1716

@kbilkhoo

Description

@kbilkhoo

Describe the bug
Request.Form containd no data

To Reproduce

client side

    var request = new RestRequest(resource);
    var jsonData = new
    {
            Company = "Microsoft",
            ZipCode = "LS339",
            Country = "USA"

    };

    request.RequestFormat = DataFormat.Json;
    request.Method = Method.Post;
    request.AddHeader("Content-Type", "multipart/form-data");
    request.AddFile("content", file, "application/octet-stream"); 
    request.AddJsonBody(jsonData);


    var response = client.ExecuteAsync(request).Result;

server side

   var request = HttpContext.Current.Request;
   Request.Form[0]; // index out of range exception

Expected behavior

    Request.Form[0]; // expected data

Stack trace
There is not stack trace for this issue. Except behaviour has changed
after upgrading from 106.13.0 to 107.1.1

106.13.0 -> Request.Form contains key called 'application/json'
107.1.1 -> Request.Form no data

Desktop (please complete the following information):

OS: Windows 10
.NET version 4.7.2
Version: 107.1.1
Additional context

workaround

changed request.AddJsonBody(jsonData) ->request.AddParameter("application/json", JsonConvert.SerializeObject(jsonData));
has resolved the issue in 107.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting-feedbackNeed feedback after the issue is fixed in previewbug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions