This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

API esios ree
#21
Use grp.create: https://openrb.com/docs/lua.htm#grp.create
Reply
#22
thanks for the reply.
Would it be possible to do it automatically, specifying a minimal virtual object up to a maximum?

regards
Reply
#23
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
Reply
#24
Does it work if you send the same request using curl?
Reply
#25
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: "
Reply
#26
Can you send your access token via PM?
Reply
#27
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?
Reply
#28
thanks a lot, I'll write them, if any news, I'll come back
Reply
#29
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);
})
Reply


Forum Jump: