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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Put a variable into JSON request for Webs.Content

Hello!

 

Currently I want to pull JSON file from a public open database API, like this:

 

Sourcekeys = Json.Document(Web.Contents("https://xxxxx.xxxx.xx/yyyyy/api/v1/zz/abcde/2021/opqrstu"))

 

However, this open database will be updated each year with same link except change in year.

 

How do I replace the year 2021 as Date.Year(Date.LocalTime) or something like that?

 

Thank you before hand 🙂 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi  @Anonymous ,

 

You can try:

let
    startDate = Date.StartOfYear( Date.From( DateTime.LocalNow() ) ) ,
    endDate = Date.EndOfYear( Date.From( DateTime.LocalNow() ) ),
    endDateText = Date.ToText( endDate, "yyyy-MM-ddT00:00:00Z" ),
    startDateText = Date.ToText( startDate, "yyyy-MM-ddT00:00:00Z" ),
    Custom1 = "https://openapi.ariba.com/api/analytics-reporting-details/v1/prod/views/templatename?realm=myrealm&filters={""createdDateFrom"":"& startDateText &",""createdDateTo"":"&endDateText&"}"
in
    Custom1

Check the similar thread below:

https://community.powerbi.com/t5/Power-Query/Rest-API-Dynamic-Date-Query/td-p/956246

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi  @Anonymous ,

 

You can try:

let
    startDate = Date.StartOfYear( Date.From( DateTime.LocalNow() ) ) ,
    endDate = Date.EndOfYear( Date.From( DateTime.LocalNow() ) ),
    endDateText = Date.ToText( endDate, "yyyy-MM-ddT00:00:00Z" ),
    startDateText = Date.ToText( startDate, "yyyy-MM-ddT00:00:00Z" ),
    Custom1 = "https://openapi.ariba.com/api/analytics-reporting-details/v1/prod/views/templatename?realm=myrealm&filters={""createdDateFrom"":"& startDateText &",""createdDateTo"":"&endDateText&"}"
in
    Custom1

Check the similar thread below:

https://community.powerbi.com/t5/Power-Query/Rest-API-Dynamic-Date-Query/td-p/956246

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

 

Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

You can add something like

    thisYear = Date.Year(DateTime.LocalNow()),
    url = "https://xxxxx.xxxx.xx/yyyyy/api/v1/zz/abcde/"&Text.From(thisYear)&"/opqrstu",
    Sourcekeys = Json.Document(Web.Contents(url))

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors