0

I ran this line of code and got the error mentioned in title. Can someone tell me what is happening?

x = requests.get('https://api.covid19api.com/total/country/india/status/confirmed').json()

I have imported the following libraries

import requests
import pandas as pd
from statsmodels.tsa.ar_model import AR

1 Answer 1

1

Your request might return 404. If that's the case, you can't decode the error pages. Therefore the following code might be a better choice:

response = requests.get('https://api.covid19api.com/total/country/india/status/confirmed')
if response.status_code == requests.codes.ok:
    response_json = response.json()
else:
    print(f"Error! Status code: {response.status_code}")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.