22.04.2022, 14:34
(19.04.2022, 07:02)admin Wrote:Code:json = require('json') http = require('socket.http') ltn12 = require('ltn12') url = 'https://developer-api.govee.com/v1/devices/control' key = '00000000-729c-4b82-b536-000000000' body = json.encode({ device = '34:20:03:15:82:ae', model = 'H6089', cmd = { name = 'turn', value = 'on' } }) resp = {} res, code = http.request({ url = url, method = 'PUT', headers = { ['Content-Type'] = 'application/json', ['Content-Length'] = #body, ['Govee-API-Key'] = key, }, source = ltn12.source.string(body), sink = ltn12.sink.table(resp), }) log(res, code, resp)
bad request as answer:
* arg: 1
* number: 1
* arg: 2
* number: 400
* arg: 3
* table:
[1]
* string: <html>
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
</body>
</html>