POSTMAN for multipage / form data
How do I use POSTMAN for Multipart / form-data that set up a header to test my controller that takes 2 files as parameter ( public ... controller( MultipartFile[] files)
)?
POST .... HTTP/1.1
.
.
.
---boundary123
Content-type:application/octet-stream
content-Disposition: form-data filenale="abc.txt" name="someuniquename"
[paylaod content](this is in xml format)
---boundary123
content-type:application/json
content-Disposition:form-data name="metadata"
{ID:"999"}
---boundary123
source to share
This is a long known problem for Postman. This can be a little tricky if you have a setup that includes, say, text or JSON for one part, but say a picture for the other. The key is to set the header Content-Type
to multipart/mixed
and then convert everything to a file. You can ignore the "convert it to file" step if it's text :)
Left this comment on: https://github.com/postmanlabs/postman-app-support/issues/1104
Ninja Update : Not sure if this will help anyone else, but there is a workaround for a specific scenario where you have multiple file / content types uploading in one multipart POST request.
- Set the
Content-Type
header tomultipart/mixed
. - Select an option
form-data
inBody
. - Convert all your elements to files. The string content should become a text file, etc.
- Add each file by selecting by
file
adding key name.
This approach does not require manually specifying each Content-Type
or Content-Disposition
. The trick was to serialize all relevant content to a persistent file type. Hope this helps someone!
source to share