# 422 Unprocessable Entity: {"detail":[{"type":"missing","loc":["body","email"],"msg":"Field required"}]}

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

## 根因

客户端发送的 JSON 正文缺少必填字段，或发送了表单数据而期望 JSON，导致 Pydantic 验证拒绝请求。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   class UserIn(BaseModel):
    email: EmailStr
    name: str = ''
   ```
2. **** (85% 成功率)
   ```
   from fastapi import Form
@app.post('/u')
async def create(email: str = Form(...)): ...
   ```

## 无效尝试

- **** — Hides the real cause; clients still send invalid payloads and data is dropped. (85% 失败率)
- **** — Still required in Pydantic v2 unless a default is provided. (70% 失败率)
