Help with HTTP POST

I have previously been able to use the following GET command to display a notification on my Kodi screen...


I am trying to change this so it works using HTTP POST instead, is this possible? I have read through a few posts and getting really confused

This driver from @ogiewon is a very simple way to do it.

Cheers, I am struggling to know what the URL path should be to use with this driver?

Also, in the IP address box, can i pass a username and password?

That's one of the reason I like this HTTP driver more. You just put in the whole URL, and it does it. BUT, it only does GET, not POST.

Kodi now only accepts POST commands, I have been able to send GET in previous versions by using the send message command built into Hubitat but can't do this any longer...

Ah, then that driver above won't help you. Then the first one referenced is probably the one you need.

No idea on if you can put a user/pass with the IP though. Try it and see...

I'm no http request expert but I've banged my head against this problem enough times to know that POST requests usually require a bit more than just passing info through the uri. Most times it requires you to choose a content type (json, txt, html, etc) and sometimes requires content to be included in the header and/or body.

Like I said, I'm no expert, but I use the Postman application and try every combination I can think of till is succumbs to my ignorance/stubbornness. In your case I suspect that your content type is "application/json".

I did and no luck, however I don't know what I should be putting into the URL section based on what my working GET command was...

You could also try use RM to send the POST. This is what the config screen looks like.

Try putting this in the uri

And everything after the equal sign in the body.

That was the first thing I tried, I see in the logs that it is trying to send something.

I'll post over on the Kodi forums as I guess I need to know what format the system is expecting...

It’s probably


Maybe @josh can help since he worked on the ST version of this.

Check out a program called Postman. It will allow you to play around with the message and might help you figure out how it has to be formatted.

Looking back at my ST-Kodi code, it looks like I was using the same GUI.ShowNotification JSONRPC call:

ST-Kodi: showNotification()

def showNotification(title, message, image="info"){
	sendCommand("GUI.ShowNotification", [ "title": title, "message": message, "image": image ])

...and I was doing it with an HTTP POST as OP is looking to do:

ST-Kodi: sendCommand()

def sendCommand(command, parameters=null, id=null){
	state.lastCommand = command
	def content = [
        "id": 1
    //if the parameters and id were passed in, add them to the JSON command
    if(parameters) content.put("params", parameters)
    if(id) content.put("id", id)
	def json = new groovy.json.JsonBuilder()
    def payload =
    log.trace "Sending command: ${command}"
    def path = "/jsonrpc"
    def headers = [:] 
    headers.put("HOST", getHostAddress())
    headers.put("Content-Type", "application/json")
    	def pair ="$username:$password"
        def basicAuth = pair.bytes.encodeBase64();
    	headers.put("Authorization", "Basic " + basicAuth )

    def method = "POST"
    def result = new physicalgraph.device.HubAction(
        method: method,
        path: path,
        body: payload,
        headers: headers

Muchas Gracia @josh

I threw together a notification driver for this.
@philpugh Have at it!


This is awesome, does exactly what I wanted :slight_smile:
Do you use Kodi @stephack?

There is another ST app that I think @josh also wrote... One that reads Kodi state. I was using this in ST to track videoplaying status and change lighting when we played a movie. I have been unable to get this working fully in ST. I am able to pause / play etc from Hubitat but unable to get any info back

The state driven part of the ST-Kodi app relies on UPnP eventing. It works best with Kodi devices that are kept ON all the time so it can keep the UPnP event subscriptions in place.

It has some fall backs using the associated SmartApp for scheduling healthchecks on the UPnP subscriptions... so unless you've ported both the DTH and the SmartApp, you may experience some difficulty with the UPnP event subscriptions.

(Similarly, some Android devices are weird about UPnP eventing and block it)

Edit: And it has a manual fallback where tapping refresh will query for the current state rather than waiting for events.

Haven't used it in years but I figured I'd get some more practice building notification driver's :wink:.

I actually wanted to learn a bit more about formatting POST requests in HE. Making this driver helped. Glad to hear it's what you needed.

1 Like

I've managed to get the App and Driver installed but device discovery didn't find anything...

I manually added the info into the settings on the driver screen and have been able to send notificiations, play, pause, etc... basically all the buttons seem to do what they are intended. But I don't see any status returned. I have just noted your comment about Android though, I am using an Nvidia Shield

Yeah, there's probably a few things that would need to be tweaked from the SmartThings version of the driver to get it to work in Hubitat. By manually entering the configuration details into the driver, you get the basic control capabilities which all happen over HTTP, but UPnP events won't work properly without the SmartApp. Here's a thread that covers many porting details:

Like, @stephack, I haven't personally used Kodi in several years so I didn't port the DTH/SmartApp over... but the code is out there and anyone is welcome to port it and take stewardship!

1 Like