[SOLVED] Problems Sending JSON

  • Platform information:
    • Hardware:x86-64(intel core i7)/8GB/14TB
    • OS: Ubuntu Server 14.04.5 LTS
    • Java Runtime Environment: Java SE Runtime 1.8.0_181
    • openHAB version: OpenHAB2 latest (apt-get)
  • Issue of the topic:
    I am trying to send JSON via rules. I have tried searching and copying strategies that others seem to have gotten to work but they are not working for me.
    I have tried httprequest route
    I have tried curl with executeCommandLine several different ways including removing spaces and replacing with @@, using var to make the curl command hidden from executeCommandLine
    I don’t understand it because this would be the first rule I have used but all I am trying to send is {“SystemON”:“on”} as json format to a local ip address.
    full curl command is : curl -H “Content-Type: application/json” -X POST -d ‘{“SystemON”:“on”}’ http://192.168.0.253/SystemON
    I have sent it with terminal as my user and as openhab user with sudo -u and both work perfectly but for some reason will not work in a rule.

I am hoping someone can explain how and the best way to send this. From an item directly if possible but if not through a rule.
I can’t tell if the rule has fired because my logs don’t seem to show the button change states for any of my buttons but I know they work because my lights are controlled perfectly fine.

This is for a iZone ducted aircon controller if that helps at all. I couldn’t find anything for iZone control anywhere either so on a side note if someone has this setup I would love to know what you have done.

Thanks in advance guys.

var String jsonString = "{\"SystemON\":\"on\"}"
sendHttpPostRequest("http://192.168.0.253/SystemON", "application/json", jsonString)
1 Like

You sir, are a champion.
Thank you for your help on that.
Turns out I wasn’t escaping the "