OpenHAB REST and Stringify

restapi
stringify
httppost
Tags: #<Tag:0x00007f18297d1bd8> #<Tag:0x00007f18297d17f0> #<Tag:0x00007f18297d16b0>

(davorf) #1

Hello!

I was wondering if anyone is using Stringify to trigger an OpenHAB item via REST API? I’ve tried Strigify’s Connect: Maker, and requesting item state via HTTP GET works but I’m not sure how to send command using a HTTP POST in it to a REST API. The URL parameter is self-explanatory, but I’m kinda stuck with a data part - it has 5 options: No data, Form data, JSON data, File via multipart formdata and Form data from query string. When choosing Form data or JSON data, you get 4 fields (Field 1 name, Field 1 value, Field 2 name and Field 2 value), but I’m not sure where should I put item state, and in what form.

Best regards,
Davor


(Rich Koshak) #2

Install and look at the REST API documentation (its under UIs in PaperUI). It tells you what to put for each field.


(davorf) #3

Hello!

I have documentation installed, and I’ve checked it, but the problem is, I can’t seem to find text/plain content type (which I suppose is necessary for OH REST API). Even if I choose other content type, it leaves me with 2 parameters, where OH REST expects only ON/OFF (for switch item, of course). I haven’t found a way to change content type in REST documentation - it has a combo box, but the only option is text/plain, for both PUT /items/{itemname}/state and POST /items/{itemname}. Is there a way to send JSON as a body, instead of text/plain? Just to mention that I’m already using REST API via Tasker without problems, but in Stringify I can’t make it work (maybe they just aren’t compatible). I have a workaround using HTTP GET and classicui/CMD? but I would rather use official API, in case this workaround gets removed in the future.

Best regards,
Davor


(Rich Koshak) #4

It is isn’t in the drop down then it isn’t supported. I don’t know anything about Stringify and am surprised it doesn’t support text/plain for the body.


(davorf) #5

Hello!

Yeah, it’s pretty silly it supports formats much more complex, but does not support text/plain. Thank you for your help. For now, I’m gonna stick with classicui/CMD? approach.

Best regards,
Davor