I’m attempting to push a device state update to Losant using the HTTP REST API.
Just to clarify - I know how to do this using other methods. For project-specific reasons, I need to be able to do this using a raw TCP socket (without SSL, just for testing).
I’ve constructed an HTTP POST packet with appropriate contents for a deviceState POST:
POST /applications/[APPLICATIONID]/devices/[DEVICEID]/state HTTP/1.0
Content-Type: application/json
Accept: application/json
Authorization: Bearer [TOKENHERE]
Content-Length: 37
{ "data" : { "Flow_mlMin":"10.1"} }
The Losant API server is responding with a 503 Service Unavailable though. I’ve tested my socket against Google (getting the homepage) and it works, so the socket itself is OK.
Any idea what else could be wrong with my HTTP POST packet (or anything else)?
I’ve tested my function for obtaining a device authentication token and it seems fine, so I think the issue is unrelated to authentication.
Does Losant accept HTTP 1.0? Anything I might be missing here?
Welp, nevermind… looks like the issue was caused by HTTP 1.0. I switched to 1.1, added a Host: header, now it’s working.