Sending images from openhab via Gotify

I was looking for a way to send messages from Openhab to gotify. I came across this thread: Gotify Push Messaging [solved]
It worked so far, but I wanted to send a picture for a certain application. As described in the documentation: Message Extras · Gotify

I worked on this for a while until I got the whole thing to work, and this is the result:

val String gotify_server = "https://your-gotify.server/message?token=<your app token>>"
val String gotify_headers = "application/json"

rule "Send Image to Gotify"
when
        Item Test changed from OFF to ON
then
        // image-URL
        val imageUrl = "https://gotify.net/img/logo.png" //a local image stored in html folder also should be possible
        // message text
        val messagetext = "some text"
        // gotify-message-details
        val gotifyMessage = "{ \"message\": \"" + messagetext + "![](" + imageUrl + ")\", \"extras\": {\"client::display\":{ \"contentType\": \"text/markdown\" }} }"
        // send to gotify
        val response = sendHttpPostRequest(gotify_server, gotify_headers, gotifyMessage)

        // Log for debugging
        logInfo("Gotify Response", response)
end

Since I didn’t get it right the first time either, I hope I can give you a little help.

You can find out how to set up Gotify in the gotify docs (I can´t post more than 2 links, so you have to search for it :wink: ):

Best regards! :sunglasses: