# fastapi.exceptions.HTTPException: 422: Unprocessable Entity - json_invalid: JSON decode error

- **ID:** `python/fastapi-body-not-json`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The request Content-Type is application/json but the body is malformed JSON (trailing comma, single quotes, empty body).

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (93% success)
   ```
   import json
body = json.dumps({'name': 'x'})
requests.post(url, data=body, headers={'Content-Type': 'application/json'})
   ```
2. **** (95% success)
   ```
   requests.post(url, json={'name': 'x'})
   ```

## Dead Ends

- **** — Accepting non-JSON violates the API contract. (85% fail)
- **** — FastAPI then rejects because the endpoint expects a Pydantic body. (90% fail)
