Hello,
I am playing around with Infura and decided to test how it would work with python requests library. I noticed that some of calls do not work properly.
I can get blockByNumber
just fine, like this:
url = “https://mainnet.infura.io/v3/API-KEY”
request_content = {“jsonrpc”:“2.0”, “method”: “eth_blockNumber”, “params”: [], “id”: 1}
request = requests.post(url, json=request_content)
Returns expected blockNumber in results
However, some POST fail when used with requests
for unknown reasons. This doesn’t happen when executing with curl
. Ie.
url = “https://mainnet.infura.io/v3/API-KEY”
request_content = {“jsonrpc”:“2.0”, “method”: “eth_getBlockByNumber”, “params”: [“0xA7EB23”, “false”], “id”: 1}
request = requests.post(url, json=request_content)
eth_getBlockByNumber
works fine with curl, but fails with requests.
{“code”:-32602,“message”:“invalid arguments to eth_getBlockByNumber”}
I suspect that “false” is a culprit here, as queries without boolean values seem to pass fine. Ie. eth-getCode