Help Sending a curl request (UPDATE KODI)

Hi Everyone

I’m trying too get OpenHAB too update my Kodi library,

I have tried too follow a tutorial post for on how too do this but i’m getting errors and cant work out how too do it that way,

there were no responses on that topic so maby that way doesen’t work anymore topic below

so too google too find a different way here is what i found

Snippet from site

4 HTTP (does not work in v18 Leia)
To add new content to the library (Update):


I have entered it into my browser it does update my kodi libary how do i get openhab too send the request ?

I do have the http binding installed

Configure a Switch Item with the HTTP binding configured to issue a GET to that URL on an ON command. See the HTTP binding for details.

Or you can use the sendHttpGetRequest from a Rule. Since it is a GET instead of a PUT or a POST with a required body, this is pretty easy.

However, because the request contains { and : you may need to escape or even double escape those special characters. E.g.: request=\\{"jsonrpc"\\:... which is double escaping the characters. Without the escapes the HTTP binding config parser will treat those special characters as part of the config instead of as part of the binding.

1 Like

Thanks rich I’m not sure I fully understand that but I will give it a try

Quick question it says that updating the libary using http will not be supported after v18 and that’s the next stable release should I just look at using one of the other methods they said

Command line using curl

Python scripts

I would. They are definitely saying it won’t work after that point so I wouldn’t waist your time. I don’t use Kodi so I couldn’t tell which of their other approaches are reasonable. But I can say using curl is just making HTTP calls so that won’t be an option.


There was no note about curl not working only the http version

Maby standard HTTP is no longer supported because the user and password are before the host name of the kodi machine I read that this is pretty much a dead thing in the http world and maby the team have stopped this from working but using a command line curl is still possible?

If I understood how this would work better I would post on the kodi Fourom

I read that to mean in version 18 the HTTP interface will no longer work. The following two examples ARE HTTP so it is telling you that these two examples will no longer work when you get to v18.

Nope. There is no difference (from Kodi’s perspective) between a browser or curl hitting that URL. It’s all an HTTP GET call and both have the user and password as part of the URL (it’s called Basic Auth).

Ok rich

as I’m not sure about this sort of stuff I’m going and I know you are more experienced in some of this stuff im going too take your word on this one

How about using a python script?

I don’t know. I know nothing of Kodi’s API.

Me neither I have not done much work with any api openhab introduced me too the concept it intruduced me too alot of new stuff

I think it’s a json api quite diverse and it does say the libary can be updated using python I will have a look see if I can find more info

Thanks for the pointers

Hi guys,

Please follow the last link in the HOW-TO: JSON-RPC API. Kodi supports two different interfaces. A HTTP API and the newer JSON-RPC API. First one will be deprecated in v18. Second one is a HTTP- and/or raw TCP socket-based interface. Meaning curl request are possible but with a different syntax than before. If you read carefully through the examples you can see the difference.

Using HTTP Basic Authentication is IMHO a bad idea. But using curl should be the way to go. Please try something like this:

curl -su <USER>:<PASSWORD> -H "Content-type: application/json" -X POST -d '{"jsonrpc":"2.0","method":"VideoLibrary.Scan","id":1}' http://<IP>:8080/jsonrpc
1 Like

Hi Thanks for the reply

I also agree with this and don’t like it myself as credentials are sent over an unencrypted connection and could easily be stolen, I’m also not much for the way kodi internally stores credentials in a plain text file called passwords it’s pretty studid

Thanks for the clarification on that

I will have a look into using a curl request but this is the first time I have tried this so…

@cweitkamp sending that from openhabian command line worked perfectly thanks for that

can you point me in the right direction for how too add that into a rule so it can be triggered by a switch as i don’t want too type it into the command line everytime i want too run it

do i need too create a script and have openhab run that ?
or use the exec binding

thanks for any pointers

Create a shell script and call it via executeCommandLine from a rule. Don’t start with exec binding for that purpose.

1 Like

Ok I will have a look into that

The tutorial linked in your first post of this topic should solve your issue.

This still works, you just need to get your linux permissions sorted.

openHAB executes shell scripts with the user openhab not the user openhabian. You also may need to make the script executable:

chown openhab <shell script>
chmod +x <shell script>

Hi @job thanks for the reply

OK i will look into that too

I’m still new too Linux I know alot about Windows but decided too take the leap and learn some Linux for my openhab setup

It takes alot of reading too get anything working but I’m happier running on Linux now

@cweitkamp hi again thanks for the pointer I will look into that aswell I’m not at my computer at the moment


I ran the commands you recomended it says this opperation is not permitted i stored the kodi script in /home/openhabian/ not in the scripts folder

[15:39:29] openhabian@openHABianPi:~$ chown openhab
chown: changing ownership of '': Operation not permitted
[15:45:27] openhabian@openHABianPi:~$ chmod +x

Moving the script too the scripts folder and running the first command returns error

chown: cannot access '': No such file or directory

You need to be root to change the ownership of a file.

sudo chown openhab:openhab

And once the ownership of the file has changed, you will need to be either the openhab user or root to change the file permissions.

sudo chmod a+x

As @rlkoshak already mentioned, use “sudo”. “sudo” is nothing more than executing another command with elevated permissions. It’s exactly the same as “Run as Administrator” in the windows environment.

1 Like