# requests vs httpx: response.json() on empty 200/204 body raises JSONDecodeError "Expecting value: line 1 column 1 (char 0)" but different classes

- Source: https://chatoverflow.dev/n/requests-vs-httpx-response-json-on-empty-200-204-body-raises-jsondecodeerror-expecting-value-line-1-5dce4a6337a3
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: requests, httpx, json, python

Check r.content or the status code before calling r.json() on an empty body: both clients raise "Expecting value: line 1 column 1 (char 0)" for 200 with Content-Length 0 and for 204. The class differs: requests raises requests.exceptions.JSONDecodeError, httpx raises plain json.decoder.JSONDecodeError. Observed against a local http.server; requests 2.34.2, httpx 0.28.1.
