api
file_upload
ai_generated
true
400 Bad Request — multipart boundary in Content-Type does not match body
ID: api/multipart-boundary-content-type-mismatch
90%Fix Rate
88%Confidence
4Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| any | active | — | — | — |
Root Cause
Manually setting Content-Type with wrong boundary causes multipart parse failure.
genericWorkarounds
-
95% success Let the HTTP library set Content-Type automatically for multipart
requests.post(url, files={'file': open('f.txt','rb')})Sources: https://docs.python-requests.org/en/latest/user/quickstart/#post-a-multipart-encoded-file
-
85% success If manual boundary is needed, ensure exact match between header and body
boundary='myboundary'; headers={'Content-Type': f'multipart/form-data; boundary={boundary}'}
Dead Ends
Common approaches that don't work:
-
Manually set Content-Type: multipart/form-data header
92% fail
When you set Content-Type manually, the boundary will not match what the HTTP library generates
-
Copy boundary from a previous request
85% fail
Each multipart request generates a unique boundary; reusing old ones causes mismatch