Whenever I try to run the script using the below code I get this error,
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
import requests
r = requests.get('https://reqbin.com/echo/get/json')
print(r.json())
I don’t get it, it seems simple and I was just following an example I found online.
I tried different ways of coding this and they all give me the same error.
Can someone please explain why is it happening?
2
Answers
Without any headers, it returns with a
403
error. Try setting'User-Agent'
:result:
TLDR you were blocked (and so was I). Your JSONDeodeError or whatever it was was because there was no JSON to parse. AS for your implementation, you did it correctly. This is on their end, not yours.