26.05.2020, 08:19
Use this:
Code:
https = require('ssl.https')
url = 'https://api.windy.com/api/point-forecast/v2'
body = [[{
"lat": 49.809,
"lon": 16.787,
"model": "gfs",
"parameters": ["wind", "dewpoint", "rh", "pressure"],
"levels": ["surface", "800h", "300h"],
"key": "abcd123"
}]]
resp = {}
res, code, hdrs, stat = https.request({
url = url,
method = 'POST',
headers = {
['Content-Type'] = 'application/json',
['Content-Length'] = #body,
},
source = ltn12.source.string(body),
sink = ltn12.sink.table(resp),
})
resp = table.concat(resp)
log(res, code, hdrs, stat, resp)