问题
I am using jquery ajax to pass json rpc request to remote server. Here is my json string:
{"jsonrpc":"2.0","method":"merchant_check","params":{"hostID":150999,"orderID":107,"amount":"7777","currency":"051","mid":15001038,"tid":15531038,"mtpass":"12345","trxnDetails":""},"id":107}
I am getting this error:
{"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"Invalid JSON-RPC 2.0 request error (-32600)"}}
What am I doing wrong? Thanks for help.
回答1:
It may be the JSON liberary the service is using. Try the following:
- Put spaces between the end of a key string+colon amd tje value, "key": "value" vs "key":"value"
- Try putting the request id as a string, "id": "1" vs "id": 1
- I don't know how well ist was coded, the service, but if you have malformed parameters, it may give you the-32600 error, instead of -32602. So what kind of currency are you using that requires no decimal and gets sent as string? What is a "mid", an integer?
Your request object looks good, it think it's what the service is expecting and calling good or bad request object.
回答2:
I had the same problem using json-rpc net. The problem was caused by the content-type
header. By default it was being set to application/x-www-form-urlencoded
by my browser and it generated that error. Setting it to application/json
fixed my issue.
来源:https://stackoverflow.com/questions/9988733/json-rpc-error-32600