HTTP POST command to start playlist remotely
#1
I used to start playlists on my Kodi 17 box with a JSON RPC command.
Unfortunately Kodi 18 no longer supports this command.

Can someone please advise which HTTP POST command I would have to use to start a playlist?

I did use search but I couldn’t find a solution. I’m not a software developer so please bear with me.
Reply
#2
Anyone?

I used to use the following command but it no longer works. It worked like a charm on Kodi 17:

http://192.168.1.3:8888/jsonrpc?request={"jsonrpc":"2.0","id":"1","method":"Player.Open","params":{"item":{"file":"special://profile/playlists/music/music.m3u"}}}; return false;

I apologize if I posted this in the wrong forum.
Reply
#3
Might be better off in Music forum. @DaveBlake is a whiz with this.
My Signature
Links to : Official:Forum rules (wiki) | Official:Forum rules/Banned add-ons (wiki) | Debug Log (wiki)
Links to : HOW-TO:Create Music Library (wiki) | HOW-TO:Create_Video_Library (wiki)  ||  Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
Reply
#4
Moved to JSON forum
My Signature
Links to : Official:Forum rules (wiki) | Official:Forum rules/Banned add-ons (wiki) | Debug Log (wiki)
Links to : HOW-TO:Create Music Library (wiki) | HOW-TO:Create_Video_Library (wiki)  ||  Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
Reply
#5
The JSON commands have not changed in v18, just the delivery requirements of those commands. For security purposes v18 now wants POST to be used not GET when making many of the JSON requests. Hence the  JSON is not wrong, just the way you make the request.

From a command shell try

Code:
curl -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":"1","method":"Player.Open","params":{"item":{"file":"special://profile/playlists/music/music.m3u"}}};' http://localhost:8080/jsonrpc
Reply
#6
Thank you very much for your reply.
I wasn't very clear in my post. I would like to start a playlist on my Kodi box from my iPhone. This worked very well by sending the above jsonrpc command with the Siri Shortcuts widget.

Is there any command to start a playlist from a remote device?
Reply
#7
Same problem here.
I made a php webapp to start a playlist from any phone/tablet in my house.
The Apache server runs in a different computer than Kodi, although they are in the same subnet.

I used to use this http request:
Code:
http://kodi:username@ipaddress/jsonrpc?request={"jsonrpc":"2.0","method":"Player.Open","params":{"item":{"file":"plalylist,m3u"}},"id":1}

With Leia I get this error:
Code:
{"error":{"code":-32099,"message":"Bad client permission."},"id":1,"jsonrpc":"2.0"}
I understand that is caused by the fact that for security reasons, Kodi no longer accepts certain http requests.

All the proposed solutions don't work.
- I can't use curl because i'm not working on the Kodi device, but on my tablet/phone.
- I can't use the POST method, because you need to use ajax in order to send json data with the POST method, and you can't do it from another domain.
In fact I tried this script:
Code:
xhttp.open("POST", "http://kodi:[email protected]/jsonrpc", true);
xhttp.setRequestHeader("Content-type", "application/json");
xhttp.send("{\"jsonrpc\":\"2.0\",\"method\":\"Player.PlayPause\",\"params\":{\"playerid\":1},\"id\":1}");

and I get this error:
Code:
Access to XMLHttpRequest at 'http://kodi:username@KodiIpAddress/jsonrpc' from origin 'http://TabletIpAddress' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I wonder how am I supposed to start my playlists from a webapp with Leia.
Reply
#8
(2019-02-03, 17:52)philip11 Wrote: I wonder how am I supposed to start my playlists from a webapp with Leia.
 It is a good question and I wish I had a standard answer for you, unfortunately I don't. Those that made the change from GET to POST unfortunately didn't leave any user advice to go with it.
Reply
#9
Does anyone know which commands smartphone apps like Official Kodi Remote, Sybu and Constellation are using?

I would really like to upgrade from Krypton to Leia but the limitation of non-post requests is holding me back.
Reply
#10
Any news?
I'm still looking for a solution. In the meantime I'm using Krypton.
Reply
#11
Probably solved:

<?php
$url = 'http://user:[email protected]/jsonrpc';
$file = $_GET['file'];

$ch = curl_init($url);

$jsonData = array(
  'jsonrpc' => '2.0',
  'method' => 'Player.Open',
  'id' => 1,
  'params' => array(
    'item' => array(
    'file' => $file
    )
  )
);

$jsonDataEncoded = json_encode($jsonData);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($ch);

?>
Reply

Logout Mark Read Team Forum Stats Members Help
HTTP POST command to start playlist remotely1