HTTP POST binding - not working

Ok starting over with code fences…

I built a simple ESP8255 wi-fi light switch that works from my web browser as follows:
To turn light on …
To turn light off …
But does not work with openHAB HTTP binging

item as follows

Switch LightSwitch  { http= "
> [ ON  :  POST : ] 
> [ OFF: POST : ] 
" }

default.sitemap follows…

sitemap default label="My First Sitemap"
{ Switch item=LightSwitch  label="My Light Switch"

services/http.cfg follows ….(other options are default)


Discussion: The Sitemap shows a switch icon with slider button that works. The log file shows switch turning on and off when moving slider button, no errors either. But ESP8255 module does not switch. Furthermore… the ESP8255 does not seem to receive the commands… I say this because the LED is programmed to blink when receiving a command. It blinks with the web browser but not with openHAB when moving the slider button. HELP please.

did you try the item config in one line and without spaces ?

yes, but tried it again. still nothing.

on spaces… I thought thing like that make code more readable, like the curly brackets of separate lines

Did you install the http binding in paperUI?

What is your system hardware, OS?

Yes i did.

Yes Rasberry Pi 3


When you use the browser it uses GET not POST.

I replaced POST with GET and log show errors. anyway… GET did not help. When i enter this simple command in browser
it switches. All I want is for openHAB to send this simple url

Openhabian or self installed ?

Try this in the command line of your RPI.

sudo -u openhab curl

Did you try

Switch LightSwitch  { http= ">[ON:POST:] >[OFF:POST:]" }
Switch LightSwitch  { http= ">[ON:GET:] >[OFF:GET:]" }

Switch LightSwitch  { http= ">[ON:POST:] >[OFF:POST:]" }
Switch LightSwitch  { http= ">[ON:GET:] >[OFF:GET:]" }

Switch LightSwitch  { http= ">[ON:] >[OFF:]" }

I am having a similar problem with a device that responds to http curl
it appears I need to deal with the cookies …

  1. I used the Hassle-free Setup SD card image
  2. The SSH command line works ( Thank you - great information ) so…now I know the RPI is capable of switching my device and my url syntax is correct :smiley:
  3. I tried all of your examples, but none work, I even tried the one with the asterisk and the one with the word CHANGED .
  4. when I do a save, the 9001 Log File gives me the following error
Binding configuration of type 'http' of item 'LightSwitch"' could not be parsed correctly.
' doesn't contain a valid binding configuration

When I programmed the ESP82266, I make the blue on-board LED blink for 2 seconds, indicating a received URL (even a one with an invalid suffix after the :8880, such as:8880/xyz/123 will still blink the LED. Bottom line is that the URL is not being sent from the HTTP binding… but is being properly sent when using SSH command as you suggested.
I have also done a fresh install, down-loaded the SD card image and reinstalled everything.
One thought that came to mind is that the HTTP binding could be expecting the normal http port of :80 whereas I am using :8880. I used 8880 because my ISP may not allow me running a port 80 server. The :8880 works well and allows me to use my router’s IP when away from home.

A guess from me is that it is not meant to define the port.
So the : are recognized as the divider for the postcontent which does not match a valid espression so the last part is taken as contetn for the post message.

Switch httpTest { http=">[*:POST:]"}

Executing url '' via method POST, with body content 'ON'
Switch httpTest { http=">[*:POST:]"}

Executing url '' via method POST, with body content '8088:default'

As expected it is not designed to take ports.
You might raise an issue in github for the binding.
Try it without the port, one of those.

Switch httpTest  { http=">[ON:POST:] >[OFF:POST:]"}
Switch httpTest  { http=">[ON:POST:] >[OFF:POST:]"}

This works for me on openHAB 2.3.0-SNAPSHOT Build #1219

Could you adapt what I have done here ?

Using the HTTP binding to do GETs at regular intervals.
Using sendHttpPostRequest() from rules. No problem specifying an URL:port there.

It’s fixed :smiley: Thanks to all for the help and the valuable work-arounds and test methods, and especially Dim Angelos who had it right when he asked if I tried it without spaces and all on one line. Apparently I missed a space somewhere when I tried it :blush: It’s so difficult to see those spaces. The HTTP binding does not work if an item has is a space after the first quote symbol and the or a line feed between the ON OFF sections… however spaces are optional but not required between the ON OFF sections.

I must have lead myself astray by what I have practiced as good programming form, lining similar things up with spaces and line feeds, but NOT in openHAB. Possibly the HTTP binding is overly restrictive on parsing. I must now assume all parsing is extremely sensitive to spaces in openHAB. Possibly VS has an option to show spaces as little blank squares, that would help.

1 Like

@highvoltage could you please post the solution for completeness sake! And does it work with the port definition?

I removed all spaces EXACTLY like in the HTTP binging examples and put everything on one line. I initially used spaces and spread things out over multiple lines just like I did when I programmed my Arduino devices in C++, for better readability, but openHAB does not tolerate spaces between elements (like a space after an apostrophe) .

Anyway… on the extended port stuff like the it works great. My application is for a SonOff switch that I re-flashed.

There seems to be a quirk though, with error log reporting when using a POST that has an ON and OFF section. The space as show in the examples, (just before the second right arrow ) separating the ON and OFF sections is required for it to work but not reported as a parsing error if omitted. This gives the illusion that it is OK to omit the space as there is no error reported. Similarly and extra space there (2 spaces) is not reported as an error, but also fails. With good eyesight and if one meticulously follows spacing in the HTTP examples and does not rely on errors log alone, things will be just fine. Beware that one and two spaces can look very similar. It would be nice if VS editor could be configured to show spaces as little blank squares.


Open VSCode, goto “File/Preferences/settings”, enter the line below into the right panel and save.
In the left panel at the top you can search for settings in the default files.

"editor.renderWhitespace": "all",

1 Like

I don’t understand. Is this a way to show blanks as white spaces? Where do I enter the line you gave me? I’m not versed in VB. Don’t understand the Git not found error either. I only use the basics… to Open, Edit (type) , and Save a file. Learning curve on VB looks steep.

@highvoltage yes this is a way to show whitespaces in VSCode. I added a description of how to set it.