Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insomnia REST Client - Set "Content-Type" for multipart/form-data

TL;DR How can I set the Content-Type headers for each individual file/input/text in a multipart/form-data request (in Insomnia)?

I'm trying to POST to the OneNote API (HTTP description) using the Insomnia Rest Client. Per the documentation, I need to submit a multipart/form-data request with one file/text with headers:

Content-Type: text/html Content-Disposition: form-data; name=presentation

and another with the headers:

Content-Type: application/inkml+xml Content-Disposition: form-data; name=presentation-onenote-inkml

Here is a screenshot of what I am trying: headers As you can see, the API returns an error with No Content-Type leading me to believe that the Content-Type header is not set. The debug information is below: debug The POST data is hidden, which does not allow me to see the Content-Type.

like image 347
Diode Dan Avatar asked Jul 31 '17 22:07

Diode Dan


People also ask

Does REST API support multipart form data data format?

Multipart/Form-Data is a popular format for REST APIs, since it can represent each key-value pair as a “part” with its own content type and disposition. Each part is separated by a specific boundary string, and we don't explicitly need Percent Encoding for their values.

Is insomnia a rest client?

Insomnia is one of the fast REST clients that's available for Windows, Mac, and Linux. Insomnia REST client is a Free Cross-Platform Desktop Framework for testing RESTful applications. It incorporates sophisticated features like code creation, security helpers, environment variables, and a user-friendly user interface.

How do I test file upload in insomnia?

Using Insomnia/Postman To upload a video using Insomnia, you have to set the body as multipart and add the file and all the other necessary parameters. The upload[file] parameter needs to be changed to type 'File' using the small arrow at the right side of the row.


1 Answers

Solution: When you use POST with the file arguments, this works. I don't know why.

solution image

like image 119
Diode Dan Avatar answered Sep 29 '22 09:09

Diode Dan