[SOLVED] Http binding: command including quotation marks - how to?

I want to arm/disarm motion detection of a camera in Shinobi. therefore I need a switch to shoot two API commands:

enable motion detection:

sendHttpGetRequest("http://xxx.xxx.xxx.xxx/[API KEY]/monitorStates/[GROUP KEY]/[PRESET_NAME]/insert?data={"monitors":[{"mid":"[MONITOR_ID_1]","mode":"start","details":{"detector":"1"}}]}")

then activate the monitor state preset:

sendHttpGetRequest("http://xxx.xxx.xxx.xxx/[API KEY]/monitorStates/[GROUP KEY]/[PRESET_NAME]")

It would be easy to have a single switch item that runs both commands, but I think thats not possible?
so I use a rule, but there is a problem with the quotation marks in the command that confuses the rule interpreter. I tried to replace " with HTML code &#34 or &quot or ’ but neither works.
What magic does the trick? thanks in advance

A lot of that has to be encoded, anyway, so do that. Double quotes, for example, would be %22.

Try single quotes:

sendHttpGetRequest('http://xxx.xxx.xxx.xxx/[API KEY]/monitorStates/[GROUP KEY]/[PRESET_NAME]/insert?data={"monitors":[{"mid":"[MONITOR_ID_1]","mode":"start","details":{"detector":"1"}}]}')

neither %22, nor ’ works

2019-01-30 09:04:11.718 [vent.ItemStateChangedEvent] - Camera_01_DetectionONOFF changed from ON to OFF

==> /var/log/openhab2/openhab.log <==

2019-01-30 09:04:11.747 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Kamera scharf schalten': Illegal character in query at index 106:{%22monitors%22:[{%22mid%22:%22SannceCam%22,%22mode%22:%22start%22,%22details%22:{%22detector%22:%220%22}}]}

When you urlencode the JSON payload it becomes:



thanks, that works!!!

1 Like

Super useful website, thanks