[Ethereum] Curl JSONRPC to localhost:8545

blockchainjson-rpc

I am trying to do a simple curl from the cmd line to my private blockchain.
I have the geth console running on localhost:8545

The curl command I am executing is the following

curl -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":67}' http://localhost:8545

I also have tried many other examples from https://github.com/ethereum/wiki/wiki/JSON-RPC

none of them work on my set up as all the responses are

{"jsonrpc":"2.0","error":{"code":-32600,"message":"invalid character '\\'' looking for beginning of value"}}}

I start geth using this:

geth --rpc --rpcapi "eth,net,web3,personal" --datadir c:\privatechain

Best Answer

windows needs the content in double quotes and those inside with \"

curl -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"net_version\",\"params\":[],\"id\":67}" http://localhost:8545
Related Topic