Search code examples
javajsonkodi

Kodi JSON-RPC over TCP invalid message


I'm sending this json over a tcp-socket to my raspi-kodi-client.

{"method":"Playlist.Clear","id":1,"jsonrpc":"2.0","params":[{"playlistid":1}]}

But he returns me:

{"error":{"code":-32602,"data":{"method":"Playlist.Clear","stack":{"message":"Invalid type object received","name":"playlistid","type":"integer"}},"message":"Invalid params."},"id":1,"jsonrpc":"2.0"}

Why??? It's look like I'm too stupidooo because diffrent examples looks same

First Example - ok its http not tcp but I dont think thats the point - but maybe it is :O

I'm using kodi 1.7 and openjdk 11.


Solution

  • In all the examples in that link, "params" is an object, not an array. And that fact is exactly what the error message is telling you (although I admit, it's not saying it very clearly).

    Simply change

    {"method":"Playlist.Clear","id":1,"jsonrpc":"2.0","params":[{"playlistid":1}]}
    

    to

    {"method":"Playlist.Clear","id":1,"jsonrpc":"2.0","params":{"playlistid":1}}