@mynameisdaniel wrote:
Trying to interface with Home Assistant from a proprietary system and not able to get it to handle POST commands. This system doesn’t support tools such as cURL, so this content is being sent through an open TCP port raw.
My header seems fine as it authenticates and GET requests work fine. Different errors when the token is changed/missing. It’s only POST where I’m having issues with the JSON data and despite trying every variation I can think of, it’s still failing.
What I’m sending to Home Assistant:
POST /api/states/binary_sensor.test HTTP/1.1$0D$0AHost: 10.220.88.81$0D$0AAccept: application/json$0D$0AConnection: close$0D$0AContent-Type: application/json$0D$0AAuthorization: Bearer [TOKEN]$0D$0A$0D$0A{"state":"0","attributes":{"source":"HDMI"}}
What I’m receiving back from Home Assistant:
HTTP/1.1 400 Bad Request$0D$0AContent-Type: application/json$0D$0AContent-Length: 38$0D$0ADate: Wed, 22 Jan 2020 00:01:02 GMT$0D$0AServer: Python/3.7 aiohttp/3.6.1$0D$0AConnection: close$0D$0A$0D$0A{"message": "Invalid JSON specified."}
If anyone has ideas on what’s failing here, or how I can troubleshoot further, that’d be appreciated!
As far as I can see I’m formatting things in a way that should work, and match what I’m getting back.
Posts: 1
Participants: 1