Ask a Question

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

meanbcp
New Contributor

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

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.

 

6 REPLIES 6
TanyaYatskovska
SmartBear Alumni (Retired)

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/

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



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!

TanyaYatskovska
SmartBear Alumni (Retired)

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

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



dboone
New Contributor

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

 

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.

TanyaYatskovska
SmartBear Alumni (Retired)

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

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



cancel
Showing results for 
Search instead for 
Did you mean: