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:
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:
The POST data is hidden, which does not allow me to see the Content-Type
.
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.
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.
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.
Solution: When you use POST
with the file arguments, this works. I don't know why.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With