How to send autentication key via sendHttpPutRequest?

(Christoph Wempe) #1

I already asked this some years ago, and found a work around using executeCommandLine.!topic/openhab/TkM6l0vZIU0

Bu I hope there is a better solution available now.

Or would it make sense to create a feature request to enhance the sendHttpPutRequest command?

One use case would be to use it for the Grafana API.

(Rich Koshak) #2

At some point a line needs to be drawn. I’m weary of expanding the HTTP Actions to the point where every possible combination of headers and bodies can be sent. I’d be more in favor of making a full HTTP library available to the Rules, something better than the default Java HTTP libraries. By the time we will be done enhancing the Actions we will have built our own library anyway so let’s just skip that and let someone else do the work. :wink:

But since that isn’t possible right now, you can use the default Java HTTP libraries. You can see some examples OAuth2 using just OH Rules and and iCloud device data integration in openHAB. Using these libraries you can craft any HTTP command with any headers or body that you need. But the code will be lengthy and ugly compared to what we usually have available to us in Rules.

Or if you are using JSR223, any of the Python, JavaScript, and Groovy libraries are available to you. Python requests makes creation of HTTP REST commands like this pretty easy.

(Scantineau) #3

A trick could be to use the http binding addon

According, you could define an item with your key and send the value from the rule to this item.

(Christoph Wempe) #4

I will look into this.