I am trying to make a post request to this website: https://www.myetherapi.com/. I'm not sure what is wrong with my request, but print(res)
returns <Response [403]>
and print(res.json())
returns the error:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Code:
import requests
import json
url = 'https://api.myetherapi.com/eth'
headers = {'content-type': 'application/json'}
payload = {
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": ["0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8", "latest"],
"id": 1
}
res = requests.post(url, data=json.dumps(payload), headers=headers)
print(res)
print(res.json())
Any idea on what I am doing wrong?
Edit:
I had posted this question and then turned off my computer. when I returned a few hours later and read the answers on this thread, i ran the code again and it worked. Then a few minutes later it's not working again. All i did is browse some web pages between the time it worked and stopped working. I am running this in pycharm. How i am running it