Hello,
I have a "HomeCenter 3 lite" and would like to send a "PUT" request to another client via HTTPClient.
In the HCL (2) I solved this with a virtual module.
For example, I can enter the following URL in the browser:
http://192.168.178.70:3777/hook/hc3l.php?Test=1.
With this URL, I can properly evaluate the parameter Test = 1 in my PHP-script.
Now I'm trying to send this data (e.g 'Test=1') within a Lua script via HTTPClient. Unfortunately I am not successful.
In this example, I tried to send a json-string.
Table = {ID = 44, Status = true, Power = 20, Energy = 2.601, Test = 1}
JTable = json.encode(Table)
selfhttp = net.HTTPClient()
url = 'http://192.168.178.70:3777/hook/hc3l.php'
sendData = JTable
header = {
["content-type"] = 'application/x-www-form-urlencoded; charset: UTF-8',
["content-type"] = "application/json"
}
selfhttp:request(url, {
options = {
method = 'PUT',
headers = header,
data = sendData,
timeout = 5000
},
success = function(response)
print('response data: '..response.data)
print('response status: '..response.status)
end,
})
The called PHP script is executed and the outputs of the program are reported back via success (response.data) - response.status is 200.
Unfortunately, the transferred data is not recognized in the program. Even simpler data packets do not arrive (e.g. '{Test = 1}').
I have also tried this simplified version as an alternative:
ocal http = net.HTTPClient()
http:request('http://192.168.178.70:3777/hook/hc3l.php?Test=24', {
success = function(response)
print('response data: '..response.data)
print('response status: '..response.status)
end,
})
Can someone give me an hint, how to transfer data to the target URL.
Thanks and regards
cervicor