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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
EwoutVlugNL
New Member

Dynamic Date Range API

Hello, 

 

My API has hardcoded dates in the URL. How could i update this where "todate" is today?

 

= Json.Document(Web.Contents("https://v9.footfallcam.com/FootfallCam/exportData?infoJson={""cat"":""0"",""id"":[""-1"",""30247"",""37499"",""30754"",""32500"",""33899"",""33829""],""data"":[],""fromdate"":""15/02/2024"",""todate"":""20/02/2024"",""period"":""1"",""dateformat"":""dd/MM/yyyy""}&access_token=480030004500680041006C00640055003300420047004E006F004C00640044005A00560043007100580067007000660075006B00490051003200550033005900760052006F0075002F007200770030005A0053002F0079003700590068004200420045003700430071007700…….”))

 

I have tried the following, with the posts on this community:

= Json.Document(Web.Contents("https://v9.footfallcam.com/FootfallCam/exportData?infoJson={""cat"":""0"",""id"":[""-1"",""30247"",""37499"",""30754"",""32500"",""33899"",""33829""],""data"":[],""fromdate"":""01/01/2023"",""todate"":""" & DateTime.ToText(DateTime.LocalNow(), "dd/MM/yyyy") & """,""period"":""1"",""dateformat"":""dd/MM/yyyy""}&access_token=480030004500680041006C00640055003300420047004E006F004C00640044005A00560043007100580067007000660075006B00490051003200550033005900760052006F0075002F007200770030005A0053002F0079003700……"""))

 

However, this wound work because PowerBI gives me an error:
(500): Internal Server Error
Details:
DataSourceKind=Web
DataSourcePath=https://v9.footfallcam.com/FootfallCam/exportData

When changing the date 20/02/2024, to today 22/02/2024, the data will load, however is the an option to automate this? 

I believe there is! Could you help?

1 REPLY 1
Vijay_A_Verma
Super User
Super User

""" & DateTime.ToText(DateTime.LocalNow(), "dd/MM/yyyy") & """
SHOULD BECOME
"& DateTime.ToText(DateTime.LocalNow(), "dd/MM/yyyy") &"

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors