How to use POSTMAN for Multipart/form-data which has customize header for testing my controller which 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
UPDATE: I have created a video on sending multipart/form-data requests to explain this better. Actually, Postman can do this. You DON'T need to add any headers, Postman will do this for you automatically. Be careful with explicit Content-Type header.
To use it, we need to select the x-www-form-urlencoded tab in the body of their request. We need to enter the key-value pairs for sending the request body to the server, and Postman will encode the desired data before sending it. Postman encodes both the key and the value.
Steps to use 'Multipart/form-data ' in Postman
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.
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