0

I need to check backend with POST JSON-RPC request. Tried everything, does not work, backend can't parse body. Any idea what I am doing wrong?

curl -vX POST http://localhost:5555 --data '{"jsonrpc":"2.0", "method":"xxx", "params":[],"id":1}'
* Connected to localhost (127.0.0.1) port 5555 (#0)
> POST / HTTP/1.1
> User-Agent: curl/7.37.1
> Host: localhost:5555
> Accept: */*
> Content-Length: 53
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 63 out of 63 bytes
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Sat, 22 Aug 2015 15:28:33 GMT
< Content-Length: 39
<
{"id":1,"jsonrpc":"2.0","result":true}

I tried this config:

option httpchk POST / HTTP/1.1\r\nContent-Type: application/json\r\nContent-Length: 53\r\n\r\n{"jsonrpc":"2.0", "method":"xxx", "params":[],"id":1}

1 Answer 1

0

You'd probably need to properly escape the string used for the check.

You've got

option httpchk POST / HTTP/1.1\r\nContent-Type: application/json\r\nContent-Length: 53\r\n\r\n{"jsonrpc":"2.0", "method":"xxx", "params":[],"id":1}

While I think this might work better

option httpchk POST / HTTP/1.1\r\nContent-Type:\ application/json\r\nContent-Length:\ 53\r\n\r\n{"jsonrpc":"2.0","method":"xxx","params":[],"id":1}

The differences are the slash after the : for both Content-Type and Content-Length headers and the removal all the spaces in the JSON "body".

I haven't tested this, but I can't see why it wouldn't work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .