Forum Discussion

rasierapparat's avatar
rasierapparat
New Contributor
4 months ago
Solved

How to set different Content-Types in multipart/form-data POST Request?

I have a REST API, that I can curl correctly, but I can not get it done in ReadyApi.
I have to upload a picture and a json string, which has the content-type "type=application/json":

curl -X 'POST' 'http:/localhost:12345/rest/add' -H 'Content-Type: multipart/form-data' -F 'picture=@/home/my.jpg' -F 'criteria={"personId":"string"};type=application/json'

I ticked "Post QueryString" and selected multipart/form-data. When I look up in the RAW tab, I see, that for criteria no content-type is set. 

The error message in ReadyApi says:
Content type 'application/octet-stream' not supported

It is necessary for me to set the content-type of my criteria JSON Object to "application/json". Otherwise I will get this error. 

I am on ReadyApi 3.45. Does anyone have a clue, how to solve the problem?

  • Hey SK2

     

    Ok, so that's a step in the right direction! 

     

    Those backslashes are going to be required when executing this in the IDE as Python code, we just needed to remove them for basic CLI interaction. 

     

    For Python and the TC IDE, you will receive that error if you do not have the indentions correct. I would make sure you're indenting properly, and add those slashes back.

     

    For instance, this is how I have mine setup and launches Chrome without any popups.

     

1 Reply

  • I  don't know, if it is the only solution, but I figured out, that you can attach the json as a *.json file and configure the content type in the attachements tab. 

    I really think, this needs improvement from Smartbear. Its very underwhelming to solve such basic config by such a workaround...