Logic Machine Forum
API - 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 (/showthread.php?tid=5945)



API - Amelie - 25.03.2025

I want to download the data of the solar production of the site from elia and based on the estimated PV production load the battery during the night. In order to minimise or electricty consumption during peak hours. For that, elia provides an api. But, my script in the LM used to work, but since a couples of month it isnot working anymore.

The script is as follows:
Code:
--
--------------------------------------------------------------------
-- BEGIN SCRIPT --
--------------------------------------------------------------------
--
require('socket.http')
require('ltn12')
require('json')

vraag = 'https://opendata.elia.be/api/explore/v2.1/catalog/datasets/ods087/records?where=datetime%20%3E%3D%20%222025-3-25%22&group_by=date_format(datetime%2C%20%27dd%2FMM%2FYYYY%27)%20AS%20Datum%2C%20date_format(datetime%2C%20%27HH%3Amm%27)%20AS%20Tijdstip%2C%20monitoredcapacity%20As%20Totaalvermogen%2C%20mostrecentforecast%20As%20Voorspelling&limit=96&refine=region%3A%22East-Flanders%22&refine=datetime%3A%222025%22&refine=resolutioncode%3A%22PT15M%22'
log(vraag)

res, code = socket.http.request({
  url = vraag,
    method = "GET",
})

log(res,code)
 The result I get is:

Code:
Elia verbeterd copy 25.03.2025 14:23:33
* string: https://opendata.elia.be/api/explore/v2.1/catalog/datasets/ods087/records?where=datetime%20%3E%3D%20%222025-3-25%22&group_by=date_format(datetime%2C%20%27dd%2FMM%2FYYYY%27)%20AS%20Datum%2C%20date_format(datetime%2C%20%27HH%3Amm%27)%20AS%20Tijdstip%2C%20monitoredcapacity%20As%20Totaalvermogen%2C%20mostrecentforecast%20As%20Voorspelling&limit=96&refine=region%3A%22East-Flanders%22&refine=datetime%3A%222025%22&refine=resolutioncode%3A%22PT15M%22
Elia verbeterd copy 25.03.2025 14:23:38
* arg: 1
  * nil
* arg: 2
  * string: Try again


What am I doing wrong. When I paste the string directly in to a brower, I get the data. So, the error is not caused by the string.


RE: API - admin - 25.03.2025

Check DNS and gateway settings in System config > Network > Interfaces.


RE: API - Amelie - 25.03.2025

Thank you, it resolved the issue.