v18 Updated JSON command for KODI 18
#1
Wink 
Hi guys after reading this post I have no idea on how to implement the changes and as a result I'm 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, I'm not a programmer so I haven't the slightest clue on how to manipulate it so that it fully works on 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"}

Any help would be greatly appreciated 

in case you are wondering why 

(as a side note,I run KODI on a dedicated windows machine (server2016) I'm trying to use this command as a command that the UPS software will issue to the PC to shutdown when on battery power during a power outage, currently the UPS send the shutdown signal to the OS and as a result, the OS just kills kodi instead properly quitting KODI, I have discovered that KODI can shutdown the computer after it has  properly taken care of itself and as a result  both KODI and the OS are quite happy with the command outlined above, so im trying to have the UPS send the shutdown signal to KODI instead of the OS, I believe it has support for batch files, yes I'm on windows, the software for the UPS is viewpower it runs as a windows service)
Reply
#2
As mentioned in the post you linked, any request that's not simply reading data must be done with a POST request, not a GET (which happens when you enter a url in a browser). The most straightforward way to send a POST request is with a command line utility like curl, example here.
Reply
#3
I see a lot of people asking how to send commands by post. Each programming language has its own routines and some similar.
I use VB6 and use the following to shutdown

  Dim myMSXML, response as string
    Set myMSXML = CreateObject("Microsoft.XmlHttp")
    myMSXML.Open "POST", "http://ipaddress:8080/jsonrpc?request=", False
    myMSXML.setRequestHeader "Content-Type", "application/json"
    myMSXML.send "{""jsonrpc"": ""2.0"", ""method"": ""System.Shutdown"", ""id"":1}"
    response = myMSXML.responseText

I think it would be a good idea if other people that use different languages to program list examples here.

any body else want to contribute.
Reply
#4
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
#5
(2019-03-06, 23:24)Graeco-Roman Wrote: 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.

Thanks a lot
Reply
#6
(2019-03-01, 21:06)MrTarantula Wrote: As mentioned in the post you linked, any request that's not simply reading data must be done with a POST request, not a GET (which happens when you enter a url in a browser). The most straightforward way to send a POST request is with a command line utility like curl, example here.

Can I still do this?
http://192.168.0.51:8081/jsonrpc?request={"jsonrpc":"2.0","method":"Playlist.Insert","params":[0,0,{"directory":"special://profile/playlists/music/Christian.xsp"}]}
It does not work for me.
Reply
#7
I am trying to play my Christmas.xsp playlist from webcore. It has worked before but recently I cannot get it to work.
This is the log error from Kodi :
DEBUG: JSONRPC: Incoming request: {“jsonrpc”:“2.0”,“method”:“Player.Open”,“id”:1,“params”:{“item”:{“file”:“special://profile/playlists/music/Christmas.xsp”}}}
ERROR: Open - error probing input format, special://profile/playlists/music/Christmas.xsp

This is the log from Kodi when I play the playlist from within Kodi. This plays correctly.
2019-10-20 09:26:32.240 T:1467982560 DEBUG: JSONRPC: Incoming request: [{“jsonrpc”:“2.0”,“method”:“Playlist.Insert”,“params”:[0,0,{“directory”:“special://profile/playlists/music/Christmas.xsp”}],“id”:142}]
Reply
#8
See this post. It looks like playback of playlists via RPC has changed. Now you need three steps. Clear the playlist (if needed), add the XSP to the playlist, and finally play the playlist.

json:
[{"jsonrpc": "2.0", "id": 0, "method": "Playlist.Clear", "params": {"playlistid": 0}},
{"jsonrpc":"2.0","id":0,"method":"Playlist.Add","params":{"playlistid":0,"item":{"recursive":true, "directory":"special://profile/playlists/music/Christmas.xsp"}}},
{"jsonrpc":"2.0","id":0,"method":"Player.Open","params":{"item":{"playlistid":0,"position":0}}}]

All three of these still have to be POST requests.
Reply

Logout Mark Read Team Forum Stats Members Help
Updated JSON command for KODI 180