# fastapi.exceptions.RequestValidationError: Body 有 1 个验证错误
body -> username
  字段必填 (type=value_error.missing)

- **ID:** `python/fastapi-missing-form-data`
- **领域:** python
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

端点声明了 Form(...) 但客户端发送 JSON，或声明了 JSON body 但客户端发送 form-urlencoded。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 0.100+ | active | — | — |
| 0.110+ | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   pip install python-multipart  # required for Form/File
   ```
2. **** (90% 成功率)
   ```
   async def login(username: str = Form(...), password: str = Form(...))  # and client must send application/x-www-form-urlencoded
   ```

## 无效尝试

- **** — Server starts but Form parsing still fails at runtime. (80% 失败率)
- **** — Breaks form clients; still 422 for the other content type. (65% 失败率)
