04.02.2020, 18:03
Thanks I looked an example! Here is the result:
But it still gives an error.
I am not good at scripts, may you help me ?
Thanks a lot!
Code:
require('socket.http')
socket.http.TIMEOUT = 5
data = "{'username':'user', 'password':'12345'}"
url1 = 'https://10.10.11.2:8443/api/login'
url2 = 'https://10.10.11.2:8443/api/s/default/stat/sta'
res, err, hdrs = socket.http.request(url1,data)
if res then
tbl = {}
res, err = socket.http.request({
url = url2,
headers = {
cookie = hdrs['set-cookie']
},
sink = ltn12.sink.table(tbl),
})
if res then
resp = table.concat(tbl)
log(resp)
else
alert('request 2 failed: ' .. tostring(err))
end
else
alert('request 1 failed: ' .. tostring(err))
end
But it still gives an error.
Code:
* string: {"meta":{"rc":"error","msg":"api.err.LoginRequired"},"data":[]}
I am not good at scripts, may you help me ?
Thanks a lot!