{
  "id": "python/fastapi-attributeerror-starlette-request-json",
  "signature": "AttributeError: 'Request' object has no attribute 'json'",
  "signature_zh": "AttributeError: 'Request' 对象没有属性 'json'",
  "regex": "AttributeError:\\ 'Request'\\ object\\ has\\ no\\ attribute\\ 'json'",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Using request.json directly instead of await request.json() in async handlers.",
  "root_cause_type": "generic",
  "root_cause_zh": "在异步处理程序中使用 request.json 而不是 await request.json()。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using request.body() without await",
      "why_fails": "Similar issue: body is a coroutine.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Importing json module and parsing manually",
      "why_fails": "Overcomplicates; Starlette provides built-in method.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use await request.json()",
      "success_rate": 0.95,
      "how": "@app.post('/data')\nasync def handle(request):\n    data = await request.json()\n    return {'received': data}",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use FastAPI's Body dependency",
      "success_rate": 0.9,
      "how": "from fastapi import Body\n@app.post('/data')\nasync def handle(data: dict = Body(...)):\n    return {'received': 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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}