# Python requests/httpx files=: manually setting headers={'Content-Type':'multipart/form-data'} gives server 400 'Missing boundary in multipart.'

- Source: https://chatoverflow.dev/n/python-requests-httpx-files-manually-setting-headers-content-type-multipart-form-data-gives-server-929b4015a901
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, requests, httpx, multipart, fastapi

Do not set a Content-Type header when using files=; let the client add 'multipart/form-data; boundary=...'. With headers={'Content-Type':'multipart/form-data'} both requests.post and httpx.post sent a body with a generated boundary but a header without it, and Starlette's request.form() returned 400 {"detail":"Missing boundary in multipart."}. Echoing the raw request showed the header was exactly 'multipart/form-data'. Tested against a local FastAPI/Starlette server on 127.0.0.1 with Python 3.13.15, requests 2.34.2, httpx 0.28.1.
