I’m trying to use home assistant to connect to an endpoint rest service. I have the rest command working in Postman, but am a little shaky on the Syntax within Home Assistant.
I’m quite the noob here, but just if it helps here’s a working rest entry from my sensors.yaml:
- platform: rest
resource: http://192.168.178.30:5000/mote/api/v1.0/channel/all/state
method: GET
name: Mote Square Circle LED States
value_template: '{{ value_json.state | dictsort }}'
So I’m guessing, this would at least let you see what HASS makes of it:
The switch above does send a post to the device, however, the arguments are not being passed correctly. the format is typically something like args=“1,100,10” where args are passed as a string.
I have also tried “args=1,100,10” and “1,100,10” without luck. In a cURL request the arguments are in quotes and passed as a string args=“1%2C0%2C10”’ How can I use quotes within quotes?
I think the problem is that the Content-Type header is not sent.
Experimenting with Postman (chrome extension) I found that I can post both JSON and args=value but I have to set the correct content type header, i.e. application/json or application/x-www-form-urlencoded. Without the header, the request doesn’t work.
I think the solution now would be to be able to set the content type header in the REST command config.
Hey I just used your format to post some Plex information into a HASS html sensor, and it worked perfectly - so thanks! I suspect that mixing your quotes in the headers section might not help; as all I did was I make the quote symbols consistent, and added the HASS auth type to the headers e.g. ‘x-ha-access’: ‘hasspasswrd’