Reputation: 5151
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
.
Upvotes: 28
Views: 65845
Reputation: 3214
To complete the accepted answer, just beware that as of now, there is no documented way to specify the Content-Type
of the part of the multipart request in insomnia.
There are already a couple of issues for this in their GitHub source. Like this and this one.
Upvotes: 2
Reputation: 31
The "Generate Code" command may help you find the cause of the problem. The command generates a program code, which contains the essential part of the POST data.
Upvotes: 2
Reputation: 5151
Solution: When you use POST
with the file arguments, this works. I don't know why.
Upvotes: 37