Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

I am trying to use json.load() but it is not working.

url = "http://api.worldbank.org/v2/country/all/indicator/" + ";".join(indicators) + 
source + date_range + per_page
response = requests.get(url)
print(response)
result = response.content
result = json.loads(result)
result

But I get this error any ideas?
error message

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

globalbank api defaults to XML, you need to tell it which format you need. try it like this:

url = "http://api.worldbank.org/v2/country/all/indicator/" + ";".join(indicators) + source + date_range + per_page + '&format=json'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading