# werkzeug.exceptions.BadRequest: 400 错误请求：浏览器（或代理）发送了服务器无法理解的请求。

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

## 根因

在缺少 `Content-Type: application/json` 或 JSON 格式错误的请求上调用 `request.get_json()`。

## 版本兼容性

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

## 解决方案

1. **** (93% 成功率)
   ```
   data = request.get_json(silent=True) or {}
if not data:
    return jsonify(error='invalid json'), 400
   ```
2. **** (95% 成功率)
   ```
   requests.post(url, json={'k': 'v'})  # sets application/json automatically
   ```

## 无效尝试

- **** — Output formatting config, not input parsing. (95% 失败率)
- **** — Silently accepts malformed input, masks client bugs. (80% 失败率)
