JSON-RPC over HTTP?
#7
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"
}
For the -d option, I have also tried
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'}"
But none have worked successfully

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"}
I give up on the curl syntax for now.
Thanks to all for the help
XBMC.MyLibrary (add anything to the library)
ForTheLibrary (Argus TV & XBMC Library PVR Integration)
SageTV & XBMC PVR Integration
Reply


Messages In This Thread
JSON-RPC over HTTP? - by bradvido88 - 2010-12-20, 17:24
[No subject] - by _Andy_ - 2010-12-20, 17:59
[No subject] - by darkscout - 2010-12-20, 18:01
[No subject] - by bradvido88 - 2010-12-20, 18:17
[No subject] - by bradvido88 - 2010-12-20, 19:16
[No subject] - by Montellese - 2010-12-20, 20:42
[No subject] - by bradvido88 - 2010-12-20, 20:49
[No subject] - by darkscout - 2010-12-20, 21:51
[No subject] - by bradvido88 - 2010-12-20, 21:52
[No subject] - by plumser - 2010-12-21, 19:49
[No subject] - by Adam - 2011-01-01, 04:57
[No subject] - by Montellese - 2011-01-01, 11:46
[No subject] - by toenuff - 2011-01-04, 05:26
[No subject] - by toenuff - 2011-01-04, 05:45
[No subject] - by manxam - 2011-01-05, 09:17
[No subject] - by Montellese - 2011-01-05, 10:48
Actionscript 2.0 - by TheyKilledKenny - 2011-01-07, 13:18
[No subject] - by Montellese - 2011-01-07, 14:08
[No subject] - by TheyKilledKenny - 2011-01-07, 18:41
[No subject] - by Montellese - 2011-01-07, 20:27
[No subject] - by ArcticGiraffe - 2011-08-13, 02:08
[No subject] - by topfs2 - 2011-08-13, 10:40
[No subject] - by ArcticGiraffe - 2011-08-13, 15:32
[No subject] - by topfs2 - 2011-08-13, 18:48
[No subject] - by ArcticGiraffe - 2011-08-13, 19:27
RE: JSON-RPC over HTTP? - by Richard6360 - 2016-05-22, 11:38
Logout Mark Read Team Forum Stats Members Help
JSON-RPC over HTTP?1