How to set content type for multipart/form-data part?

Originally posted by meanbcp on May 15, 2019

I have a multi-part request with two parts, a file and json metadata. The “file” part I can set the content-type through the attachment, but the “json” part seems to be defaulting to application/octet-stream which causes a 415.

POST http://localhost:9080/foo HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: multipart/form-data; boundary="----=_Part_16_1749562154.1557927365085"
MIME-Version: 1.0
Content-Length: 53766
Host: localhost:9080
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_181)

------=_Part_16_1749562154.1557927365085
Content-Disposition: form-data; name="json"

{ "foo" : "bar", "foo1" : "bar1" }
------=_Part_16_1749562154.1557927365085
Content-Type: image/jpeg
Content-Transfer-Encoding: binary
Content-Disposition: form-data; name="file"; filename="royal flush.jpg"

...

This causes a 415 Content type ‘application/octet-stream’ not supported.

Here is a snippet form the request (through Postman) which works:

Content-Disposition: form-data; name="json"
Content-Type: application/json
Content-Length: 608

{ "foo" : "bar", "foo1" : "bar1" }
--B7pQWGrOXLWmnqGJ6JvxJJWBMoXDNZn2H
Content-Disposition: form-data; name="file"
Content-Type: image/jpeg
Content-Length: 53275

...

When I change the content-type of the json part to application/octet-stream in Postman, I can reproduce the 415. So it seems if there is a way in ReadyAPI to set the content-type to application/json, I can POST successfully. But I do not see any options in ReadyAPI to do so.

Thanks for any help in advance!

Gene.

Originally posted by TanyaYatskovska on May 17, 2019

Hi meanbcp,

Could you please check if you see the same behavior in the latest ReadyAPI version - v. 2.7?

You can download it here:

https://support.smartbear.com/downloads/readyapi/

Originally posted by meanbcp on May 21, 2019

I have downloaded and installed 2.7.0, and the behavior is the same.

I need a way to explicitly set the content-type of each form part, and then it should work beautifully!

Originally posted by TanyaYatskovska on May 21, 2019

Hi,

Thanks for checking the issue with the latest product version.

I suggest that you refer this question to our Support Team so that they could investigate it:

https://support.smartbear.com/message/?prod=ReadyAPI

Originally posted by dboone on September 15, 2019

Did you get a solution to this? My request multipart/form-data does the same thing it puts the wrong content -type

Originally posted by dboone on September 15, 2019

Tanya

Do you know if this problem got resolved? I have a multi-part request with two parts, a file and json metadata. The “file” part I can set the content-type through the attachment, but the “json” part seems to be defaulting to application/octet-stream which causes a 415.

Originally posted by TanyaYatskovska on September 17, 2019

Hi dboone,

I see some investigations on this topic. However, I’m not sure if I share them with you. Could you please contact our Support Team as well and provide them with the detailed information?

https://support.smartbear.com/message/?prod=ReadyAPI