10.10.2022, 10:07 
		
	
	
		Try this:
	
	
	
	
Code:
require('socket.http')
require('ltn12')
require('json')
email = "..."
password = "..."
powerstation_id = "..."
function encodepost(t)
  local res = {}
  local esc = require('socket.url').escape
  for k, v in pairs(t) do
    res[ #res + 1 ] = esc(k) .. '=' .. esc(v)
  end
  return table.concat(res, '&')
end
body = json.encode({
  account = email,
  pwd = password,
  is_local = True,
  agreement_agreement = 1
})
token = json.encode({
  uid = "",
  timestamp = 0,
  token = "",
  client = "web",
  version = "",
  language = "en-GB",
})
headers = {
  ["Content-Type"] = "application/json; charset=utf-8",
  ["Accept"] = "Content-Type: application/json; charset=UTF-8",
  ["Content-Length"] = #body,
  ["Accept"] = "application/json",
  ["token"] = token,
}
response = {}
res, code, hdrs, stat = socket.http.request({
  url = "https://eu.semsportal.com/api/v2/Common/CrossLogin",
  method = "POST",
  headers = headers,
  source = ltn12.source.string(body),
  sink = ltn12.sink.table(response),
})
if res and code == 200 then
  response = json.decode(table.concat(response))
  headers.token = json.encode(response.data)
  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))
  invert_full = response.data.inverter[1].invert_full
  log(invert_full)
end 
 

