20.06.2023, 07:10
The response looks fine. You can modify this part to log only when api field is missing from the response, then check what the log says:
Code:
if res and code == 200 then
response = json.decode(table.concat(response))
headers.token = json.encode(response.data)
if not response.api then
log('invalid response', response)
else
url = response.api .. "/v2/PowerStation/GetMonitorDetailByPowerstationId"
response = {}
body = json.encode({ powerStationId = powerstation_id })
headers["Content-Length"] = #body
res, code, hdrs, stat = socket.http.request({
url = url,
method = "POST",
headers = headers,
source = ltn12.source.string(body),
sink = ltn12.sink.table(response),
})
response = json.decode(table.concat(response))
-- ...
end
end