RPC "code":-32700 - running on Windows 8.1 / curl version 7.41.0

+4 votes

I have started a "chain0" multichain. Completed many examples all running from command line (Windows 8.1). I am on machine_1 the one that started the -daemon and i can successfully connect on this from another machine_2.
The problem is when i try to use curl from machine_1. Every time the same error:

{"result":null,"error":{"code":-32700,"message":"Parse error"},"id":null}

Tried many commands:

Example 1:
curl -u multichainrpc:<my_pass_here> -d {"method":"getinfo","params":[],"id":1,"chain_name":"chain0"} -H "Content-Type: text/plain;" -X POST http://127.0.0.1:9710

Example 2:
curl -u multichainrpc:<my_pass_here> -d {"method":"getinfo","params":[],"id":1,"jsonrpc":"1.0"} -H "Content-Type: text/plain;" -X POST http://127.0.0.1:9710
Example 3:
curl -u multichainrpc:<my_pass_here> -d '{"method":"getinfo","params":[],"id":1,"jsonrpc":"1.0"}' -H "Content-Type: text/plain;" -X POST http://127.0.0.1:9710

And many more. 

Inside folder:
C:\Users\<user_name>\AppData\Roaming\MultiChain
i have multichain.conf file and inside that file i have the rpcpassword property set.
As stated here in another message i have already used the help getinfo command.
Trace in case that helps:
> curl -u multichainrpc:<password_here> -d {"method":"getinfo","params":[],"id":1,"jsonrpc":"1.0"} -H "Content-Type: text/plain;" -X POST http://127.0.0.1:9710 -vvvv
* Rebuilt URL to: http://127.0.0.1:9710/
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 9710 (#0)
* Server auth using Basic with user 'multichainrpc'
> POST / HTTP/1.1
> Authorization: Basic bXVsdGljaGFpbnJwYzpHTDhVS3E1N0JMRE5iOVV3SG5HVXl1VXR6UEdkZVc4aEZpTFlmOXlTcG12dA==
> User-Agent: curl/7.41.0
> Host: 127.0.0.1:9710
> Accept: */*
> Content-Type: text/plain;
> Content-Length: 43
>
* upload completely sent off: 43 out of 43 bytes
< HTTP/1.1 500 Internal Server Error
< Date: Fri, 23 Mar 2018 14:04:11 +0000
< Connection: close
< Content-Length: 74
< Content-Type: application/json
< Server: bitcoin-json-rpc/v0.10.0.0-unk
<
{"result":null,"error":{"code":-32700,"message":"Parse error"},"id":null}
* Closing connection 0
Maybe i have misunderstood a lot, i am new to blockchain. 
What i try to do is test it with curl and then create a java app in order to call it.
asked Mar 23, 2018 by kgiannis

1 Answer

+1 vote

This will likely be an issue with how curl is picking up parameters from the command line. You might want to try using multichain-cli instead, which takes care of building the JSON-RPC request for you, but still shows it on the command line for your reference.

answered Mar 25, 2018 by MultiChain
multichain-cli works perfect, i just wanted to also test it with curl.

Solution in case anybody else has the same issue:

curl -u multichainrpc:<my_pass_here> -v -H "Content-Type: application/json" -d "{\"id\":0, \"method\":\"getinfo\",\"params\":[]}" http://127.0.0.1:7420

i had to escape the (") characters
Great, thanks for sharing this.
Thanks this worked for me too after a long time of suffering
...