To add to this problem, by adding &format=xlsx
to the GET string it is possible to obtain the file data in that format.
In the browser there is button that do that and is interpreted by the broswer as a download and get the file. Using the developer tool of the browser i can see it is a GET request and so i wrote this piece of code but while it definetly write something, because the file have some data in it, it doesn't allow me to open it saying that the format is not valid.
local net = require "net"
--by adding the "&format=xlsx" it is possible to receive the data in a different format
local client = net.Http("https://marine-api.open-meteo.com")
local task=client:get("/v1/marine?latitude=54.544587&longitude=10.227487&hourly=wave_height,wave_direction,wave_period,wind_wave_height,wind_wave_direction,wind_wave_period&wind_speed_unit=kn&forecast_days=1&format=xlsx")
task.after=function(self, response)
local file=sys.File("C:\\Program Files\\luaRT\\LuaRT-Studio\\Projects\\Some Gui App\\Meteo\\test.xlsx")
file:open("write")
file:write(response.content)
file:close()
end
waitall()
If instead i format it in csv and create a .csv file i can just create the file on my pc as i was downloading it, the problem is only with the xlsx extension.
if possible i would like to understand how to fix both codes cause in the future i want to do more stuff with http and socket library so the more i understand about this the better
Thanks a lot for reading all of this, hope the solution is easy to find.