2010-12-20, 20:49
Montellese Wrote:I never used curl on windows before but there are two things I noticed in your example:
1. Don't set XBMC to provide the JSON-RPC API on port 80 because port 80 is the default port for HTTP requests to the WWW.
2. You're request is missing the "id" field (which you can see in the HTTP response).
Thanks for the tips.
1) Is there a way to specify a different port for the JSON-RPC api to listen on. I thought it is always the same port as the web server. Either way, I changed it to 8000 and it did not help.
2) I added and id, but it's not returning it
I think the problem lies in the syntax of my command. curl is not seeing the data as a single object. It seems like its trying to connect to each parameter as though it thinks it's a server by the "Could not resolve host: 2.0" etc. messages.
Code:
c:\curl>curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlayer.PlayPause", "id": "1"}' -u xbmc:xbmc http://localhost:8000/jsonrpc
curl: (6) Could not resolve host: 2.0,; No data record of requested type
curl: (6) Could not resolve host: method; No data record of requested type
curl: (6) Could not resolve host: AudioPlayer.PlayPause,; No data record of requested type
curl: (6) Could not resolve host: id; No data record of requested type
curl: (3) [globbing] unmatched close brace/bracket at pos 2
HTTP/1.1 200 OK
Content-Length: 115
Content-Type: application/json
Date: Mon, 20 Dec 2010 18:46:37 GMT
{
"error" : {
"code" : -32700,
"message" : "Parse error."
},
"id" : 0,
"jsonrpc" : "2.0"
}
Code:
"jsonrpc=2.0&method=AudioPlayer.PlayPause&id=1"
"{jsonrpc: 2.0, method: AudioPlayer.PlayPause, id: 1}"
"{""jsonrpc"": ""2.0"", ""method"": ""AudioPlayer.PlayPause"", ""id"": ""1""}"
"{'jsonrpc': '2.0', 'method': 'AudioPlayer.PlayPause', 'id': '1'}"
EDIT: I have gotten this to work successfully by telnetting to the raw TCP 9090 port and sending this exact string:
Code:
{"jsonrpc": "2.0", "method": "AudioPlayer.PlayPause", "id": "1"}
Thanks to all for the help