POSTMAN for Multipart/form-data
I hope this will help others avoid long debugging efforts. Bottom line is that for some multipart uploads, you're just flat out of luck. For instance, if you need to do multipart/related, and need to express that in the Headers with a Content-Type, Postman can't help you. Primarily that's because Postman ONLY generates a random boundary, even if you add your own. The difficult part is that Postman will claim to be using your boundary in the Postman Console, but will actually be using a different boundary in the call. Thus the header boundary declared and the boundary actually used won't match.
Here's an example of a request from Postman, viewed both in the Postman Console and also in Fiddler. As you can see, Fiddler shows Postman is actually sending a random boundary, where Postman is claiming to use the provided boundary.
I really hope they fix that in Postman. At least show it the Postman Console, even if they don't fix the underlying issue. It's a great tool for most APIs, but if you're trying to hit a DICOM server, and being compliant about it... you're out of luck.
Steps to use 'Multipart/form-data ' in Postman
- Create a new tab
- Insert controller Url
- Set method type as POST
- Under Body tab, select form-data
- For each key that is a file, set Value type as File
This is a long-known issue for Postman. It can be a bit tricky if you have a set up that involves using say text or JSON for one part but say a picture for another. The key is to set the Content-Type
Header to multipart/mixed
and then to convert everything into a file. You can ignore the "convert it into a 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 types / content types being uploaded in a single multipart POST request.
- Set the Header
Content-Type
tomultipart/mixed
. - Select the
form-data
option inBody
. - Convert all of your items into files. String content should become a text file, etc.
- Add each file by selecting
file
, adding a key name.
This approach doesn't require actually manually specifying each Content-Type
or Content-Disposition
. The trick here was to serialize all relevant content into a persistent file type. Hope that helps someone!