02.03.2020, 10:00
Hi everyone,
I have been trying to do a scheduled script to obtain data from the PVPC Active energy billing term default tolling (https://www.esios.ree.es/es/analisis/102...oupby=hour) every day.
Using the API provided by the web to download this information (https://api.esios.ree.es/) , I tried the next script:
But i receive this log:
* arg: 1
* string: error:1409442E:lib(20):func(148):reason(1070)
* arg: 2
* table:
I don't know what i'm doing wrong. I will appreciate any help.
I have been trying to do a scheduled script to obtain data from the PVPC Active energy billing term default tolling (https://www.esios.ree.es/es/analisis/102...oupby=hour) every day.
Using the API provided by the web to download this information (https://api.esios.ree.es/) , I tried the next script:
Code:
https = require('ssl.https')
json = require('json')
ltn12 = require('ltn12')
payload = ''
token ='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
Token=('Token token=\34'..token..'\34')
-- pedirlo automaticamente aqui: consultasios@ree.es
now = os.date('*t')
tom= os.time(os.date('*t')) + 86400 --mañana
--tom= os.time(os.date('*t')) --hoy
tomorrow = os.date("*t", tom)
day = tomorrow.day
month = tomorrow.month
year = tomorrow.year
--log (now, tom, tomorrow)
url = 'https://api.esios.ree.es/indicators/10229?start_date='..day..'-'..month..'-'..year..'T00%3A00&end_date='..day..'-'..month..'-'..year..'T23%3A50' --Término de facturación de energía activa del PVPC
log (url)
-- url = "https://api.esios.ree.es/indicators/10229?start_date=02-03-2020T00%3A00&end_date=02-03-2020T23%3A50" --Término de facturación de energía activa del PVPC
response_body = {}
body, code, hdrs, stat = https.request ({
url = url;
method = 'GET';
headers = {
['Accept'] = 'application/json; application/vnd.esios-api-v1+json';
['Content-Type'] = 'application/json';
['Host'] = 'api.esios.ree.es';
['Authorization'] = Token;
['Cookie'] = '';
};
source = ltn12.source.string(payload);
sink = ltn12.sink.table(response_body);
})
log ( code, response_body)
if (code == 200) then
log('OK: '..tostring (code) .. ' Success on GET....' )
end
But i receive this log:
* arg: 1
* string: error:1409442E:lib(20):func(148):reason(1070)
* arg: 2
* table:
I don't know what i'm doing wrong. I will appreciate any help.