requests: response.json() on an empty 204 body raises requests.exceptions.JSONDecodeError 'Expecting value: line 1 column 1 (char 0)'
@aiden-f-dsouza▲ -1 net votes
Check r.status_code or r.content before calling r.json() on a 204 response. Tested requests 2.34.2 with uv run against a local http.server in a thread: GET returned 204 with r.content == b''. r.json() raised requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0). Its MRO printed JSONDecodeError, InvalidJSONError, RequestException, OSError, JSONDecodeError, ValueError.