Receiving http/get requests to trigger items

few changes

This is a commonly asked question if you have IoT devices which only support http GET requests (like my Mobotix cameras) but OH3 requires http POST method to trigger items from external.
There is an easy workaround to use the CMD servlet


but that is not an official feature and subject to be dropped at any time.
There are also quite a few solutions for a get to post converter out there but to me they seem to be complicated (like installing a couple of packages and scripts, make changes to config files etc…).
That’s why I tried to find a replacement which is as easy as possible to implement, ideally without any additional apps.

Easy solution:
Below is an html code which you have to copy-paste into an .html file and enter an API Token. Copy the file (any file name will do) to a directory of your choice in




That’s it!
the syntax is almost the same like the CMD servlet:


I know, I could have done the code below even better, like making use of the constructor URLSearchParams() but I wanted to have it as compatible as possible with older web clients like IE.
html code:

<!DOCTYPE html>
	<script type="text/javascript">
			const apiToken = "oh.get2post.tPmn1XUBj5EulsGg1TpIE15HRUhFpv0sUbPF2DydYF1ITOQ1LzHaqwkeFVPFdppUYK3YE0fByjGWKA"
			const strHost =;    //replace with e.g. "openhab:8080";
			const debug = true;
			const strParam = (window.location + '').split("?");
				if (debug) console.log("strHost: '" + strHost + "', strParam: '" + strParam[1] + "'");
			//if ((strParam.length == 1) || (strParam[1] == "")) {
			//	console.log("Parameter not found");
			var item = strParam[1].split('=')[0];
			var cmd = strParam[1].split('=')[1];
				if (debug) console.log("item: '" + item + "', command: '" + cmd + "'");
			if (window.XMLHttpRequest) {
				//code for modern browsers
				var req = new XMLHttpRequest();
			} else {
				// in case your IoT web client is based on an old IE engine
				// this is NOT tested
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}"POST", "http://" + strHost + "/rest/items/" + item);
			req.withCredentials = true;
			req.setRequestHeader("Content-Type", "text/plain");
			req.setRequestHeader("Accept", "*/*");
			req.setRequestHeader("Authorization", "Bearer " + apiToken);
			req.onreadystatechange = function () {
				console.log("Status: " + req.status);
				<li>create API Token in MainUI (<a href="">see here)</a></li>
				<li>edit index.html and enter API Token in line 7</li>
				<li>create directory CMD in openHAB-conf/html/</li>
				<li>copy index.html to openHAB-conf/html/CMD/</li>
				<li>set debug to true in index.html, line 9</li>
				<li>run URL within your browser and press F12 function key to see log output</li>
				<li>if problems, enter IP address or host name (including IP port) in index.html, line 8</li>

Hi, This would not work from IOT devices supporting only http get webhooks because those devices simply make a http GET request - however they don’t process the HTML received as the response. They don’t have browsers to do that :slight_smile:

Your solution probably works only when you use your browser to fire the mentioned



You can simulate http GET to check it in a way any devices would with a tool called curl or wget, etc.

Please check the bidning proposal here - [webhook] New, very simple binding for listening incomming http requests . This can be used with http-get-only webhook devices.

1 Like

That’s why I wanted to re-write the whole thing as a java servlet, but your http listener is exactly what I have been looking for for ages :slight_smile:
I will use it right away. Many thanks for your contribution and guiding me in this direction.

1 Like

How about making this great add-on available through this newly created marketplace?

I will try to make a pull request to main addon repository and have it in official distribution. Thx

(post deleted by author)