Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

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!

1 ACCEPTED SOLUTION
tackytechtom
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,

 

Can you try this? 🙂

 

Json.Document(Web.Contents("https://api.carbonintensity.org.uk/regional/intensity/" & Date.ToText(DateTime.Date(DateTime.LocalNow()), "yyyy-MM-dd") & "/fw48h/region/13/"))

 

Let me know if this works for you 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

2 REPLIES 2
tackytechtom
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,

 

Can you try this? 🙂

 

Json.Document(Web.Contents("https://api.carbonintensity.org.uk/regional/intensity/" & Date.ToText(DateTime.Date(DateTime.LocalNow()), "yyyy-MM-dd") & "/fw48h/region/13/"))

 

Let me know if this works for you 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Anonymous
Not applicable

Thank you very much Tom! Worked like a charm and I really should start with learning the basics of the syntax 😊

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.