![]() |
|
JSON-RPC over HTTP? - Printable Version +- XBMC Community Forum (http://forum.xbmc.org) +-- Forum: Development (/forumdisplay.php?fid=32) +--- Forum: Development (/forumdisplay.php?fid=93) +---- Forum: JSON-RPC (/forumdisplay.php?fid=174) +---- Thread: JSON-RPC over HTTP? (/showthread.php?tid=88117) |
JSON-RPC over HTTP? - bradvido88 - 2010-12-20 17:24 I currently have some custom scripts that update my XBMC library automatically but they are using the (depricated) HTTP API. I'd like to switch to the JSON-RPC API, but I am having trouble finding an example of how use the interface. I've read the wiki and have enabled the webserver. Browsing to httpL//mybmc/jsonprc tells me that json-rpc is up and running. So, now I want to use the interface....
Thanks for the help. I've been reading up on JSON-RPC, but am new to this, so I'm hoping my questions make sense. - _Andy_ - 2010-12-20 17:59 1) No. You have to wrap your json query in a POST request to your desired port. You can configure the http port in XBMC. You can use raw port 9090 too. You need to send your request in brackets {} only. 2)I use an simple app in objective c to test the response. I guess you can find some easy phyton examples which are part of XBMC too. - darkscout - 2010-12-20 18:01 http://boshdirect.com/blogs/tech/set-xbmc-to-auto-update-library.html Or if you just want to use curl. Code: curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlaylist.Add", "params": { "file": "/home/xbmc/Music/Adele - 19/101-adele-daydreams.mp3"}, "id": 1}' http://localhost:9019/jsonrpc- bradvido88 - 2010-12-20 18:17 Thanks for the replies. I think I will try sending the parameters in a HTTP post. I will test this out tonight. Thanks - bradvido88 - 2010-12-20 19:16 darkscout Wrote:http://boshdirect.com/blogs/tech/set-xbmc-to-auto-update-library.html Ok, I'm using curl on windows. I'm trying to do a test to confirm it works. It is not working. I'm guessing my data syntax in not getting parsed correctly by the command line? Any ideas? Code: c:\curl>curl -i -X POST -d '{"jsonrpc": "2.0", "method": "AudioPlayer.PlayPause"}' -u xbmc:xbmc http://localhost:80/jsonrpc- Montellese - 2010-12-20 20:42 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). - bradvido88 - 2010-12-20 20:49 Montellese Wrote:I never used curl on windows before but there are two things I noticed in your example: 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/jsonrpcCode: "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 - darkscout - 2010-12-20 21:51 It's not curl's problem. It's Window's bastardization of command line parameters. Notice all the "Could not resolve hosts"? it's trying to look up a 2.0 as a host and do something with it. - bradvido88 - 2010-12-20 21:52 darkscout Wrote:It's not curl's problem. It's Window's bastardization of command line parameters.Yeah, that's why I was trying all the different combinations... trying to get windows to parse it correctly. maybe a windows cmd line veteran knows what the correct syntax is... or even if a syntax exists that will work. - plumser - 2010-12-21 19:49 dunno if this helps any, but i've written a simple python script to update my library. I use this on ubuntu but maybe you can adapt it for windows.. Code: #!/usr/bin/python |