{
  "id": "python/fastapi-missing-body",
  "signature": "fastapi.exceptions.RequestValidationError: [{'type': 'missing', 'loc': ['body'], 'msg': 'Field required', 'input': None}]",
  "signature_zh": "FastAPI 请求验证错误：缺少请求体，字段必填。",
  "regex": "fastapi\\.exceptions\\.RequestValidationError:\\ \\[\\{'type':\\ 'missing',\\ 'loc':\\ \\['body'\\],\\ 'msg':\\ 'Field\\ required',\\ 'input':\\ None\\}\\]",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "The request body is required but was not sent. This often happens when a POST request is sent without a body or with wrong Content-Type.",
  "root_cause_type": "generic",
  "root_cause_zh": "请求体是必需的但未发送。这通常发生在 POST 请求没有发送请求体或 Content-Type 错误时。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Setting Content-Type to text/plain",
      "why_fails": "FastAPI expects JSON by default.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Sending an empty body",
      "why_fails": "Empty body is still missing required fields.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Send a valid JSON body with required fields",
      "success_rate": 0.95,
      "how": "curl -X POST http://localhost:8000/items -H 'Content-Type: application/json' -d '{\"name\": \"item\"}'",
      "condition": "",
      "sources": []
    },
    {
      "action": "Make the body optional in the endpoint",
      "success_rate": 0.9,
      "how": "from fastapi import Body\n@app.post('/items')\ndef create_item(data: dict = Body(None)):\n    return data",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-10-12",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}