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

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
| improve this answer | |

you should add address,as follows: curl -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":67}' localhost:8545

| improve this answer | |
  • Thank you. I did have that already.. I forgot to state that in my OP... Even with that I still get the error unfortunately – Dino Anastos Aug 2 '17 at 7:15
  • At first, you must be start testrc service on single terminal, and then execute JSON RPC op. If you have get error, please tell me error log. – BinGoBinBin Aug 2 '17 at 7:20
  • the other way, start geth on single terminal: geth --rpc --rpcaddr localhost --rpcport 8545 , and then execute JSON RPC op. – BinGoBinBin Aug 2 '17 at 7:38
  • I edit the original post to include the localhost:8545 to the command. Using Parity I had to add -H "Content-Type: application/json", but it totally worked. I've seen this once or twice because the quotes were 'enhanced' quotes from autocorrect in my text editor. Type the command in full from command line as opposed to copy and paste (if you're copying and pasting). – Thomas Jay Rush Aug 2 '17 at 11:12
  • Unfortunately I am still getting the same error after typing it manually. Its driving me nuts.... Here is a screen shot ibb.co/b5mBEk – Dino Anastos Aug 2 '17 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.