• 1
  • 9
  • 10
  • 11(current)
  • 12
  • 13
  • 15
Working JSON RPC API Examples
(2018-10-22, 21:39)black_eagle Wrote:  Get is supported in V18 according to the protocol table here
As for many things Wiki is out of date. For security reasons there is a significant change in v18 that prevents GET working for most of the API commands. Use POST instead.
Reply
(2018-10-23, 13:23)DaveBlake Wrote:
(2018-10-22, 21:39)black_eagle Wrote:  Get is supported in V18 according to the protocol table here
As for many things Wiki is out of date. For security reasons there is a significant change in v18 that prevents GET working for most of the API commands. Use POST instead.  
Ah, cheers Dave, I wasn't aware of that.  The only jsonprc requests I make outside of an addon are done with curl --data-binary in bash scripts and using --data automatically makes curl use POST.  eg, to set the volume

bash:
curl -s --data-binary '{ "jsonrpc": "2.0", "method": "Application.SetVolume","params": {"volume":'50'}, "id": 1}' -H 'content-type: application/json;' http://localhost:8080/jsonrpc
Learning Linux the hard way !!
Reply
So I am trying to write webcore code to play a particular playlist (Vocal Trance). Of course, webcore has a Play Track command but not a Play Playlist command. After lots of reading I am thinking I will have to use JSON-RPC to get Kodi to play a playlist. Thoughts on how I would do that?
Reply
Example of using JSON to play a m3u playlist
Code:
[{"jsonrpc": "2.0", "id": 0, "method": "Playlist.Clear", "params": {"playlistid": 0}},
{"jsonrpc":"2.0","id":0,"method":"Player.Open","params":{"item":{"recursive":true, "directory":"C:/MyMusic/TestList.m3u"}}}]

Also seee https://forum.kodi.tv/showthread.php?tid...pid2606438
Reply
Any working solution to play a PVR channel ?
This worked before updating to kodi 18 but not anymore

{"id":1,"jsonrpc":"2.0","method":"Player.Open","params":{"item":{"channelid":167}}}

send error: Error: Server responded with error: Invalid params
Reply
(2015-07-27, 06:05)lammyoflyd Wrote: http://192.168.1.107/jsonrpc?request={"jsonrpc":"2.0","id":"1","method":"Player.Open","params":{"item":{"file":"special://profile/playlists/music/Morning.xsp"}}}

Thank you SO MUCH. I have been looking all over for this.
Reply
Hi,

Many good examples in this thread, a wiki by its own for many !

In case some are interested, I wrote a php script handling json/rpc for many commands, to integrate Kodi into my smarthome.
Here is the github:

https://github.com/KiboOst/php-Kodi-jsonAPI

I may make a python equivalent someday, as I may need it also.

Wink
Reply
For those of you interested in using webCoRE and JSON RPC to access the Kodi API and pass a playlist for Kodi to play.........check here.
Reply
So the above method that I am using to play a playlist with webCoRE is working very well. But, when Kodi starts playing the playlist, it plays just a couple of seconds of a song and then advances to another song and proceeds normally. How can I fix that?
Reply
Hello

i am struggling to get the json obj back in html or javascript to make a now playing display on a tablet for example.

all json codes work in the adress bar of chrome
and also if i put the json call in the htm, but i cant figure out how to get the return from kodi itself.
Quote:<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

<html>
<body>
<p>report player id and type</p>

<p id="demo"></p>

<script>

var myObj, i, j, x = "";
myObj = {
  "id":"1",
  "jsonrpc":"2.0",
  "result": [
    {
       "playerid":"1", "type":"video"}
  ]
}
for (i in myObj.result) {
  x += "<h2>" + myObj.result
[i][i]</html>
</body>

</script>

document.getElementById("demo").innerHTML = x;
}
  }

.type[j];
    x +=  myObj.result

.type) {[/i]  for (j in myObj.result
.playerid + " : ";[/i]

[i][i] Can someone give me a help with it ?[/i][/i]
Reply
There are too many things wrong with your example to even begin to look at it. The reference to JQuery needs to at least be inside the HTML tag, preferably in the head, which you're lacking. You don't appear to even be using JQuery. You have html tags inside your JS, and you have JS outside of the JS tag. Last of all, you're not making a call to JSON-RPC. Hint: use AJAX.
Reply
I am trying to find a way to read in the responce from kodi after a call to get ie the player id or title of movie wich is playing.

the example was only to test the split of the pairs of data.

i am not a js programmer. ive got experience in delphi and php only
Reply
Hello!

I want to sort the Tvshow episodes, by lastplayed date.
Code:
{"jsonrpc": "2.0", "method": "VideoLibrary.GetInProgressTVShows", "params": { "limits": { "start" : 0, "end": 75 }, "properties": [ "title", "originaltitle", "episode", "watchedepisodes", "lastplayed"], "sort": { "order": "ascending", "method": "lastplayed"} }, "id": "libTvShows"}

With this request wont work.
Can someone help me?
Thanks!
Reply
Hi guys Im having trouble with the shutdown command in KODI 18.  The command below works on kodi 17.6 but I have no luck on kodi 18. I have just read that in Kodi 18 for security reasons the API has some sort of permission levels implemented. 

When I paste the command below in my browser with kodi(17.6) running and the 'allow remote control via HTTP' setting enabled kodi will shutdown my entire computer after quitting itself. Which is exactly what I want it to do. Can somebody please help me adapt this command for kodi 18 so that it shuts down my PC with the same settings in Kodi 18

http://localhost:8080/jsonrpc?request={"jsonrpc":%20"2.0",%20"id":%201,%20"method":"System.Shutdown"}

When I try the above command on kodi 18 I get the following response

{"error":{"code":-32099,"message":"Bad client permission."},"id":1,"jsonrpc":"2.0"}
Reply
Found a solution using git
with git installed in windows and using the command below, I was able to send the command to kodi

$ curl -X POST -H "content-type:application/json" http://localhost:8080/jsonrpc -d '{"jsonrpc":"2.0","id":1,"method":"System.shutdown"}'  

to make it execute paste the command in a new notepad file,save it and change the extension to .sh

$git curl -X POST -H "content-type:application/json" http://localhost:8080/jsonrpc -d '{"jsonrpc":"2.0","id":1,"method":"System.Shutdown"}'

now I can use it in task scheduler etc to trigger graceful shutdown for kodi and server2016. Im no programmer, so its probably not very 'elegant' but it works for my use case.
Reply
  • 1
  • 9
  • 10
  • 11(current)
  • 12
  • 13
  • 15

Logout Mark Read Team Forum Stats Members Help
Working JSON RPC API Examples0