30.12.2016, 10:21
After a long session with Wireshark I gave up on this script...
I now use the following script which works:
I now use the following script which works:
Code:
require('json')
require('socket.url')
require('socket.http')
local ltn12 = require("ltn12")
path = "http://192.168.0.232:1925/1/input/key"
local payload = [[{"key" : "CursorLeft"}]]
print(payload)
local response_body = { }
local res, code, response_headers, status = socket.http.request
{
url = path,
method = "POST",
headers =
{
["Content-Type"] = "application/json",
["Content-Length"] = payload:len()
},
source = ltn12.source.string(payload),
sink = ltn12.sink.table(response_body)
}
print('Response: = ' .. table.concat(response_body) .. ' code = ' .. code .. ' status = ' .. status,1,'Sample POST request with JSON data',-1)