{
  "id": "python/fastapi-body-not-json",
  "signature": "fastapi.exceptions.HTTPException: 422: Unprocessable Entity - json_invalid: JSON decode error",
  "signature_zh": "fastapi.exceptions.HTTPException: 422：无法处理的实体 - json_invalid：JSON 解码错误",
  "regex": "fastapi\\.exceptions\\.HTTPException:\\ 422:\\ Unprocessable\\ Entity\\ \\-\\ json_invalid:\\ JSON\\ decode\\ error",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "The request Content-Type is application/json but the body is malformed JSON (trailing comma, single quotes, empty body).",
  "root_cause_type": "generic",
  "root_cause_zh": "请求 Content-Type 为 application/json，但请求体是格式错误的 JSON（尾随逗号、单引号、空体）。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Accepting non-JSON violates the API contract.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "FastAPI then rejects because the endpoint expects a Pydantic body.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.93,
      "how": "import json\nbody = json.dumps({'name': 'x'})\nrequests.post(url, data=body, headers={'Content-Type': 'application/json'})",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "requests.post(url, json={'name': 'x'})",
      "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-11-21",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}