-
Notifications
You must be signed in to change notification settings - Fork 856
Multipart POST not working for me #576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Are you using the Interceptor? Might be related to #561 |
No. Its not enabled. When I click "Preview" to see the request (before submitting), I got the above out of POSTMan. Seemd like the boudary= in the headers does not match the one used in the body: boundary=----WebKitFormBoundaryp7MA4YWxkTrZu0gW
Shouldn't they be the same? |
The "Preview" boundary is not the same as the one that is sent. It's there for illustrating how the request would look like. The final request is sent by Chrome which adds the request boundary automatically. You can inspect the final request in Chrome's Network Inspector too to see if things are going through properly: http://blog.getpostman.com/index.php/2013/09/18/legacy-app-update-cookies-and-devtools-for-v0-9-x/ |
After comparing wireshark output for curl and postman, I realize that by not including the Content-Type: multipart/form-data header in Postman, I was able to successfully post the multi-part message. I still think its a POSTMan bug. Or maybe its a Chrome bug. In curl, when I do not include the Content-Type header, it adds it and if I do set the Content-Type header, it modifies it to add the boundary. But in Postman, if I set the Content-Type header, the trace in wireshark shows that it is not appended with the boundary and the API falls on the server complaining about not finding boundary. Here are my results viewing trace in wireshark: curl with Content-Type: multipart/form-data curl w/o content type: Postman with Content-Type: multipart/form-data Postman w/o Content-Type set: |
@stevemcmillen I think the issue is that the custom Content-Type header overrides the default Content-Type header that should be sent. I think Postman should just not allow a custom header for form-data as that'll be added anyway. |
Just wanted to say that this cost me 8 hours of debugging when I thought I have something wrong with my Java application. I had the custom Content-Type header present with the correct multipart/form-data value and that was the issue. |
Ugh - same here! I was pulling my hair out over how such a simple thing was failing and this was it! |
Can this issue be reopened? I also ran into this bug. If Postman is going to present a cURL command, it should be correct. The way it is now, this is going to be incorrect for all POST commands with form data. |
Same issue here. |
+1 |
+1 ... it cost me a whole night to debug my java code until I found the post works in a purl post html...then, I remove the custom header " content-type multipart/form-data" in postman, it works... |
+1 very interested in a postman solution |
+1 Same issue, I want to use the multipart upload with an additional content type. This currently will not work due to this bug. |
+1 multipart/related requests do not work either. If you remove all request headers, but have JSON post body data plus a file attachment, postman automatically adds a Content-Type=application/json header back in. If you specify Content-Type=multipart/related, the post body data gets reset to plain text which will not be accepted by endpoints expecting body data as JSON. |
Why is this closed if this is still an issue? I have wasted time also, assuming that my application was wrong. |
Is this still not solved? |
I am not sure what is the bug here? I believe we have another bug tracking that adding custom content-types individually for each multipart data. |
multipart form uploads work just fine. Just don't specify a custom Content-Type. Your content-type is going to fail otherwise because the form-data boundary is determined by the XHR library internally. If you want to use your Content-Type, then you will have to construct your request separately and paste it as text in the "Raw" mode. |
Sometimes I need a custom Content-type, and also need multipart. I finally learned cURL because of this bug. |
The only problem is that folks its not obvious you can't set a content-type header when doing multi-part but clearly that breaks the request. This can take some time to figure out why. I think what would help folks is if POSTMan did one of the following:
#1 seems like a better solution since it make it obvious to the user what is wrong |
Definitely cost me 5-6 hours of time not realizing the fix was to remove the Content-Type header altogether. This is not very transparent. Would recommend a warning tooltip or something similar. |
3B) Variant of number 3: detect that the custom content-type header starts with "multipart/" and append the newly generated boundary parameter to the Content-Type header before sending. I want to use this to send a |
For my case though, Postman could also look for the custom Content-Type header containing Maybe I should create a new feature request. |
@albertdev that's exactly what I expected postman to do. Honor the boundary if I include it in the header. |
@albertdev How did you manage to run postman and form-data? |
Badly. I simply tested my API with some custom code as a client instead. |
Not sure if things have changed recently but now the problem i have is content type is multipart/form-data for the main header. But inside the boundary it has application/octet-stream whereas my file is json so it should be application/json Is there a way to say my uploaded file is of type application/json and dont think it is application/octet-stream |
I got the same issue, but when i set the header [ enctype : multipart/form-data ], i got the result. |
Same, this happened to me as well with a few nights of wasted debugging time. |
question +1 |
still not solved. killed my morning. |
I'm experiencing the same issue. When selecting
The
This does not work if |
Here is the charles debug output:
As you can see, file is selected, but does not show in the request |
Buenas noches Oligriffiths, pudiste resolver el problema? |
Wow I wasted some time |
Came across this issue when trying to troubleshoot why my request was not working. I was setting Content-Type myself AND postman was automatically doing it behind the scenes. Not the expected behavior I was looking for and burnt some time on this (like everyone else on here).
|
I have a similar issue. The |
Thanks a lot! |
In 2020, I am getting the same error. API is working fine when posting data from HTML form but not working from the postman. Getting error "The submitted data was not a file. Check the encoding type on the form." Postman version - 7.32.0 |
+1 - ended up writing a python script using requests, which is slightly easier to work with as a test harness than curl |
Got the same issue as in 2021! Increadible |
And in 2022 too...still not working... |
@LordEvron Can you open up a new issue and share the screenshots / recording of the issue? Based on the previous comments, the issue could be a custom Content-Type being added in the request (need to verify the same). Closing this thread off to ensure that we don't miss out on any future comments / issues pertaining to this. |
I'm having an issue posting a multipart form request with POSTMan where some of the items have binary data. I think POSTMan has an error with the boundary.
I want to post a form that has three parts:
Part 1: name=photo (an image)
Part 2: name=metadata (text metadata in json format)
Part 3: name=thumbnail (a small image)
I can post the same data via CURL (See command below) and the server receives it correctly but when I submit with POSTMan, I get a general error from the server.
Error on the server reported by Java when parsing the form data is "Missing Start Boundary".
Following is output from POSTMan "Preview". The boundary reported in the headers seems to not match the actual boundary used.
And here is the CURL command that POSTMan suggests:
And here's a CURL command that works:
The text was updated successfully, but these errors were encountered: