JSONRPC is not working with me
#1
Hi, I'm trying to play around with the JSONRPC interface, but so far I'm only getting a nasty Parse Error every time.

Here's an example of my request via telnet on port 9090:

Code:
POST / HTTP/1.1

{"method": "JSONRPC.Ping", "id": "5"}

My response is always
Code:
{
   "error" : {
      "code" : -32700,
      "message" : "Parse error."
   },
   "id" : 0,
   "jsonrpc" : "2.0"
}

And this is what it has to say on my xbmc.log:
Code:
13:52:43 T:140011613701888 M:2508509184   ERROR: JSONRPC: Failed to parse '
                                            POST / HTTP/1.1
                                            
                                            {"method": "JSONRPC.Ping", "id": "5"}'

I've tried using python jsonrpc modules like json-rpc and jsonrpclib and tried using urllib directly and got the same result.

Is there a required header there that I'm not sending?
Reply
#2
you are not sending a properly formatted json-rpc 2.0 request! (looks like your sending 1.1)

This:
Code:
{ "jsonrpc": "2.0", "method": "JSONRPC.Ping", "id": 1 }
is properly formatted, please google for the jsonrpc 2.0 specification.
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply
#3
I still get the same error :/

Code:
$ telnet localhost 9090
Connected to localhost.
Escape character is '^]'.
POST / HTTP/1.1

{ "jsonrpc": "2.0", "method": "JSONRPC.Ping", "id": 1 }
{
   "error" : {
      "code" : -32700,
      "message" : "Parse error."
   },
   "id" : 0,
   "jsonrpc" : "2.0"
}
Reply
#4
Full Debug Log on pastebin please.

It works just fine here
Code:
topfs@tobias-desktop:~$ telnet localhost 9090
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
{ "jsonrpc": "2.0", "method": "JSONRPC.Ping", "id": 1 }
{"id":1,"jsonrpc":"2.0","result":"pong"}

EDIT: Your telnet states post / HTTP/1.1 that sounds wrong tbh. It should be raw tcp no actual protocol overhead.
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply
#5
Oh! Right.. That's what I was doing wrong. Thanks.
Reply

Logout Mark Read Team Forum Stats Members Help
JSONRPC is not working with me0