Python Forum
JSONDecodeError: Expecting value - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: JSONDecodeError: Expecting value (/thread-36583.html)



JSONDecodeError: Expecting value - mehtamonita - Mar-07-2022

Hi,

I'm trying to read json content from a url, however, it is displaying the below error in spite of status 200 (<Response [200]>).

JSONDecodeError: Expecting value

Below is the code:

jUrl_dummy = 'https://abc.dummy.com/rest/api/latest/search?fields=%s&query=%s'
fields_dummy = 'key,summary'
username = credentials.login['username']
password = credentials.login['password']
query_dummy = ('project = xxx')
r_dummy = requests.get(jUrl_dummy % (fields_dummy, query_dummy), auth = (username, password))
print(r_dummy)
j_dummy = r_dummy.json() --> This gives the error
Can someone please help with the resolution?


RE: JSONDecodeError: Expecting value - bowlofred - Mar-07-2022

Just because the server thinks that the query and the server's response was correct (200), doesn't mean that the response is json or that the server's response was bug-free.

Have you examined r_dummy.text or r_dummy.contentto see what the content looks like? (Although in this case it appears to be sending no data).

Could it be sending a cookie instead (which is then to be used for later requests)?