# fastapi.exceptions.RequestValidationError: JSON 解码错误：期望值：第 1 行第 1 列 (字符 0)

- **ID:** `python/fastapi-json-decode-error`
- **领域:** python
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

客户端发送了空请求体或非 JSON 请求体，而端点期望 application/json。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (92% 成功率)
   ```
   async def create(item: Item | None = None): ...
   ```
2. **** (88% 成功率)
   ```
   from fastapi import Body
async def create(item: Item = Body(default=None)): ...
   ```

## 无效尝试

- **** — Header alone does not provide parseable JSON; still fails. (85% 失败率)
- **** — Parsing occurs before the handler in FastAPI. (90% 失败率)
