JSONDecodeError when calling request.post()
Posted: Fri May 16, 2025 4:37 pm America/New_York
Hello,
I am making a request via python to login to the AρρEEARS API. When calling the request.post() function as shown here : token_response = r.post('{}login'.format(api), auth=(user, password)).json()
I get the following json decoder error :
JSONDecodeError Traceback (most recent call last)
File ~/miniconda3/envs/py3/lib/python3.13/site-packages/requests/models.py:974, in Response.json(self, **kwargs)
973 try:
--> 974 return complexjson.loads(self.text, **kwargs)
975 except JSONDecodeError as e:
976 # Catch JSON-related errors and raise as requests.JSONDecodeError
977 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError
File ~/miniconda3/envs/py3/lib/python3.13/json/__init__.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
343 if (cls is None and object_hook is None and
344 parse_int is None and parse_float is None and
345 parse_constant is None and object_pairs_hook is None and not kw):
--> 346 return _default_decoder.decode(s)
347 if cls is None:
File ~/miniconda3/envs/py3/lib/python3.13/json/decoder.py:345, in JSONDecoder.decode(self, s, _w)
341 """Return the Python representation of ``s`` (a ``str`` instance
342 containing a JSON document).
343
344 """
--> 345 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
346 end = _w(s, end).end()
File ~/miniconda3/envs/py3/lib/python3.13/json/decoder.py:363, in JSONDecoder.raw_decode(self, s, idx)
...
976 # Catch JSON-related errors and raise as requests.JSONDecodeError
977 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError
--> 978 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
This function was working without probs a few months ago. No changes in python or the request package since then.
Any help will be greatly appreciated
I am making a request via python to login to the AρρEEARS API. When calling the request.post() function as shown here : token_response = r.post('{}login'.format(api), auth=(user, password)).json()
I get the following json decoder error :
JSONDecodeError Traceback (most recent call last)
File ~/miniconda3/envs/py3/lib/python3.13/site-packages/requests/models.py:974, in Response.json(self, **kwargs)
973 try:
--> 974 return complexjson.loads(self.text, **kwargs)
975 except JSONDecodeError as e:
976 # Catch JSON-related errors and raise as requests.JSONDecodeError
977 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError
File ~/miniconda3/envs/py3/lib/python3.13/json/__init__.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
343 if (cls is None and object_hook is None and
344 parse_int is None and parse_float is None and
345 parse_constant is None and object_pairs_hook is None and not kw):
--> 346 return _default_decoder.decode(s)
347 if cls is None:
File ~/miniconda3/envs/py3/lib/python3.13/json/decoder.py:345, in JSONDecoder.decode(self, s, _w)
341 """Return the Python representation of ``s`` (a ``str`` instance
342 containing a JSON document).
343
344 """
--> 345 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
346 end = _w(s, end).end()
File ~/miniconda3/envs/py3/lib/python3.13/json/decoder.py:363, in JSONDecoder.raw_decode(self, s, idx)
...
976 # Catch JSON-related errors and raise as requests.JSONDecodeError
977 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError
--> 978 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
This function was working without probs a few months ago. No changes in python or the request package since then.
Any help will be greatly appreciated