# json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

- **ID:** `python/starlette-request-body-json-error`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The request body is empty or not valid JSON when the endpoint tries to parse it as JSON.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   Validate content-type and body: if request.headers.get('content-type') == 'application/json' and await request.body(): data = await request.json() else: return JSONResponse({'error': 'Invalid JSON'}, status_code=400)
   ```
2. **** (95% success)
   ```
   Use FastAPI's body parameter with Pydantic model to automatically handle validation errors
   ```

## Dead Ends

- **** — Catches the error but doesn't provide a meaningful response; the client still gets a 500. (50% fail)
- **** — body() returns bytes; you still need to decode and parse, same issue if empty. (60% fail)
