# fastapi.exceptions.RequestValidationError: [{'type': 'value_error.missing', 'loc': ['body', 'file'], 'msg': 'field required', 'input': None}]

- **ID:** `python/fastapi-file-upload-empty`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The endpoint expects a file upload via `UploadFile` but the request doesn't include a file part in the multipart form data.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   Ensure the client sends multipart form data with the correct field name. For testing: `client.post('/upload', files={'file': ('filename.txt', b'content', 'text/plain')})`.
   ```
2. **** (90% success)
   ```
   Make the file parameter optional: `file: UploadFile = File(None)`.
   ```

## Dead Ends

- **** — Sending the file as a JSON body doesn't work; FastAPI expects multipart form data. (95% fail)
- **** — Using `requests.post(url, files={'file': open('file.txt', 'rb')})` may fail if the field name doesn't match the parameter name. (80% fail)
