Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Help an absolute beginner with getting API for current day/ todays date

Hello world,

Absolute beginner here trying to get api data to always get today's date for below link:

= Json.Document(Web.Contents("https://api.carbonintensity.org.uk/regional/intensity/2024-02-06/fw48h/region/13/"))

 

I understand I need to replace 2024-02-06 with a function and I've tried several reiterations of the DateTime.LocalNow with no success.

I'm either getting an error that the query failed to get contents for the below:

= Json.Document(Web.Contents("https://api.carbonintensity.org.uk/regional/intensity/(DateTime.LocalNow())/fw48h/region/13/"))

 

or that there's a syntax.error ( Token ',' expected) if i try to put the function in "" as per below:

= Json.Document(Web.Contents("https://api.carbonintensity.org.uk/regional/intensity/"(Date.LocalNow())"/fw48h/region/13/"))

 

I know I must be absolutely butchering the format, but if any of you kind souls could please point me to the right solution here, I'd appreciate it very much!
Many thanks!

2 Replies