Open JustusGreiberORGADATA opened 1 year ago
The same problem using binary option: "content-type" header exist in auto-generated headers, but it isn't send in request.
I'm having almost the same issue
When there is a form-data body and you're sending only file, Content-Type header is not being set.
Here's an example of what headers are being sent with only file added to the form:
And here's an example with dummy key added to the request:
Unbelievable! This is still an issue. I had form-data
with only one File
key which is a bunch of files. Content-Type is missing in the header!
I just added another Text
key called dummy
and put a dummy value. Now the Content-Type
is included in the header!
Year 2024, and this is STILL not actually fixed... Body type = form-data
means ALWAYS include Content-Type: multipart/form-data; boundary=<calculated when request is sent>
.
I am having the same issue: empty body when using form-data
and the http method patch
patch
+ body json
= workspost
+ body form-data
= workspatch
+ body form-data
= empty body@ADTC @brnck @JustusGreiberORGADATA @ppodgorskicrido
Edit (probably solved)
This previous behavior occurs because HTML forms natively support only GET
and POST
methods. When you try to send a PATCH
request using form-data
in Postman or in JavaScript FormData()
, some server-side frameworks or setups may not properly handle this combination, leading to an empty request body.
_method
Parameter (Method Overriding):
POST
and using the _method
parameter to indicate the actual method you want to use (PATCH
, PUT
, DELETE
).PATCH /user/update/{id}
POST
request to /user/update/{id}?_method=PATCH
with the form-data
body.PATCH
request. const formData = new FormData();
formData.append('name', 'John Doe');
formData.append('photo', fileInput.files[0]);
fetch('/user/update/{id}?_method=PATCH', {
method: 'POST',
body: formData,
headers: {
'Accept': 'application/json',
},
})
.then(response => response.json())
.then(data => console.log('Success:', data))
.catch(error => console.error('Error:', error));
Is there an existing issue for this?
Describe the Issue
If you select "form-data" for the body but uncheck all key-value pairs no Content-Type header is send to the API.
If you check one key-value pair
Content-Type: multipart/form-data; ...
is automatically set.I expected the Content-Type header to be still set to
multipart/form-data
, if I wanted no automatic header, I would choose "none" for the body.But maybe this is the desired behavior.
Steps To Reproduce
Screenshots or Videos
Operating System
Windows
Postman Version
10.13.0
Postman Platform
Postman App
User Account Type
Signed Out User
Additional Context?
No response