# 400 错误请求：请求体中缺少必填字段 'email'

- **ID:** `api/rest-api-response-missing-required-field`
- **领域:** api
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

API 端点要求在 JSON 请求体中包含特定字段，但该字段被省略或设置为 null。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| REST API v2.0 | active | — | — |
| OpenAPI 3.0 | active | — | — |

## 解决方案

1. ```
   查阅 API 文档确认必填字段。将缺失的字段添加到请求体中。示例：curl -X POST https://api.example.com/users -H 'Content-Type: application/json' -d '{"email": "user@example.com", "name": "John"}'
   ```
2. ```
   在发送前使用 JSON schema 验证器（如 ajv）在本地验证请求体。
   ```

## 无效尝试

- **** — Changing the HTTP method from POST to PUT does not fix the missing field issue; the server still validates the request body. (20% 失败率)
- **** — Adding the field with an empty string instead of a valid value may cause a different validation error (e.g., 'email' must be a valid email). (50% 失败率)
