Logic Machine Forum
API esios ree - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: API esios ree (/showthread.php?tid=2496)

Pages: 1 2


RE: API esios ree - admin - 23.06.2021

Use grp.create: https://openrb.com/docs/lua.htm#grp.create


RE: API esios ree - JRP - 23.06.2021

thanks for the reply.
Would it be possible to do it automatically, specifying a minimal virtual object up to a maximum?

regards


RE: API esios ree - jose_dli - 16.02.2023

hello, esios change the header for autentification in their API, from

Code:
curl "https://api.esios.ree.es/indicators" -X GET
-H "Accept: application/json; application/vnd.esios-api-v1+json"
-H "Content-Type: application/json" -H "Host: api.esios.ree.es"
-H "Authorization: Token token=\" 96c56fcd69dd5c29f569ab3ea9298b37151a1ee488a1830d353babad3ec90fd7\""
-H "Cookie: "
to (https://apip.esios.ree.es/doc/index.html)
Code:
curl "https://api.esios.ree.es/archives" -X GET \
-H "Accept: application/json; application/vnd.esios-api-v1+json" \
-H "Content-Type: application/json" \
-H "x-api-key:\"96c56fcd69dd5c29f569ab3ea9298b37151a1ee488a1830d353babad3ec90fd7\"" \

In the script of this post I try to change:

Quote:--Token=('Token token=\34'..token..'\34')
Token=('\34'..token..'\34')
Code:
body, code, hdrs, stat = https.request ({ --Llamada HTTP formada por URL+metodo+cabecera
  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;
        ['x-api-key'] = Token;
        ['Cookie'] = '';
  };
    source = ltn12.source.string(payload);
    sink = ltn12.sink.table(response_body);
})

but, the return code is 401, error with authentification

Anyone was able to update the request to new way?

thanks for your help


RE: API esios ree - admin - 16.02.2023

Does it work if you send the same request using curl?


RE: API esios ree - jose_dli - 16.02.2023

yes, old curl (valid until end of this month) and new curl return the json. But I am not able make it works properly

curl "https://api.esios.ree.es/indicators/1001?start_date=15-02-2023T00%3A00&end_date=15-02-2023T23%3A50&geo_ids[]=8741" -X GET \
-H "Accept: application/json; application/vnd.esios-api-v1+json" \
-H "Content-Type: application/json" \
-H "Host: api.esios.ree.es" \
-H "Authorization: Token token=\"xxxxxxxxxxxxxxxxxxxxx\"" \
-H "Cookie: "



curl "https://api.esios.ree.es/indicators/1001?start_date=15-02-2023T00%3A00&end_date=15-02-2023T23%3A50&geo_ids[]=8741" -X GET \
-H "Accept: application/json; application/vnd.esios-api-v1+json" \
-H "Content-Type: application/json" \
-H "Host: api.esios.ree.es" \
-H "x-api-key:\"xxxxxxxxxxxxxxxxxxxxx\"" \
-H "Cookie: "

(16.02.2023, 14:33)jose_dli Wrote: yes, old curl (valid until end of this month) and new curl return the json. But I am not able to make it works properly

curl "https://api.esios.ree.es/indicators/1001?start_date=15-02-2023T00%3A00&end_date=15-02-2023T23%3A50&geo_ids[]=8741" -X GET \
-H "Accept: application/json; application/vnd.esios-api-v1+json" \
-H "Content-Type: application/json" \
-H "Host: api.esios.ree.es" \
-H "Authorization: Token token=\"xxxxxxxxxxxxxxxxxxxxx\"" \
-H "Cookie: "



curl "https://api.esios.ree.es/indicators/1001?start_date=15-02-2023T00%3A00&end_date=15-02-2023T23%3A50&geo_ids[]=8741" -X GET \
-H "Accept: application/json; application/vnd.esios-api-v1+json" \
-H "Content-Type: application/json" \
-H "Host: api.esios.ree.es" \
-H "x-api-key:\"xxxxxxxxxxxxxxxxxxxxx\"" \
-H "Cookie: "



RE: API esios ree - admin - 16.02.2023

Can you send your access token via PM?


RE: API esios ree - admin - 17.02.2023

Thanks. It seems that their API does not accept the key when there's a space in the key header: x-api-key: "...". HTTP library always sends headers this way. Can you contact them and ask if they can fix it on their side?


RE: API esios ree - jose_dli - 17.02.2023

thanks a lot, I'll write them, if any news, I'll come back


RE: API esios ree - jose_dli - 21.02.2023

the problem was the quotes in the token and that esios had two servers to make test.

The way is as follow:

Code:
token='xxxxxxxxxxxxxx'
body, code, hdrs, stat = https.request ({ --Llamada HTTP formada por URL+metodo+cabecera
  url = url;
  method = 'GET';
  headers = {
        ['Accept'] = 'application/json; application/vnd.esios-api-v1+json';
        ['Content-Type'] = 'application/json';
        ['x-api-key'] = token;

  };
    source = ltn12.source.string(payload);
    sink = ltn12.sink.table(response_body);
})