Hi all,
I have an issue trying to make and HTTPS POST request from my LUA scnene in Fibaro HC.
I am getting "short read" error with the URL "https://api2.magicair.tion.ru/idsrv/oauth2/token"
This is my scene:
=============================================
--[[
%% properties
%% events
%% globals
--]]
local authData = "username=XXX&password=YYY"
function doTest()
print('Test!')
local requestUrl = "https://api2.magicair.tion.ru/idsrv/oauth2/token"
local httpClient = net.HTTPClient()
httpClient:request(requestUrl, {
options = {
method = "POST",
headers = {
["Content-Type"] = "application/x-www-form-urlencoded",
["Content-Length"] = tostring(authData:len())
},
data = authData,
timeout = 5000
},
success = function (response) fibaro:debug (response.data) end,
error = function (err) fibaro:debug ("Error: " .. err) end
})
setTimeout(doTest, 5*1000)
end
print('Script start...')
doTest()
=============================================
I am getting the following in my log:
[DEBUG] 15:16:52: Script start...
[DEBUG] 15:16:52: Test!
[DEBUG] 15:16:52: Error: short read
I have been trying to play with headers, data format, timeouts and all parameters I could find, however I always get the same error with the provided URL.
Other HTTPS URLS I tried with GET method works just fine.
Also I have been trying to do the same with cURL and it works fine with the exact same set of headers and payload (with full credentials string, of course).
So the issue is somehow connected with this specific URL: "https://api2.magicair.tion.ru/idsrv/oauth2/token"
The Internet is saying that short read problem in HTTPClient request might be related to ciphering protocols mismatch between the client and server.
So there could be some parameter regulating this?
2 main versions, which I see:
1. Some tricky param is required to form the correct HTTPS request.
2. Some bug / missing feature in HTTPClient implementation in HC2.
Anyway I am stuck and need the help from the community and HC developers.
Has anyone seen something similar? Any clues?
Please help!
Many thanks in advance.
PS Using the latest FW 4.51 of Fibaro Come Center 2