Forum Discussion
Marie-Eve
2 years agoNew Member
Need help with relative path and query
Hello, I need help building my source in Power Query to link to this site https://mpr.datamart.ams.usda.gov/services/v1.1/reports/2498?q=report_date=6/19/2024&allSections=true and be able to have it...
WanderingBI
2 years agoResolver III
I think it is working with below code, you can use it either with the full url or with the relative part and the query.
Maybe the reason why you had trouble is that the API blocks you out when you do too many requests. After waiting a few minutes it will work again.
let
// Source = Json.Document(Web.Contents("https://mpr.datamart.ams.usda.gov/services/v1.1/reports/2466/Summary?q=report_date=08/05/2019"), 65001),
pathBase = "https://mpr.datamart.ams.usda.gov/services/v1.1/",
pathRelative = "reports/2466/Summary?",
pathQuery = "q=report_date=08/05/2019",
pathFull = pathBase & pathRelative & pathQuery,
Source = Json.Document(Web.Contents(pathFull), 65001),
yesterdayDate = DateTime.ToText(Date.AddDays(DateTime.LocalNow(), -1), "yyyy-MM-dd"),
queryWithTodayDate = "report_date=" & yesterdayDate,
SourceRelative = Json.Document(
Web.Contents(pathBase, [
RelativePath = pathRelative,
Query = [q = queryWithTodayDate]
])
)
in
Source
Marie-Eve
2 years agoNew Member
Hello, I was able to recreate this with the the url in my original request and tried to replicate this with prior 2 days but it's not working.
I duplicated the request and change this part to -2 but it still showed me the data of -1
yesterdayDate = DateTime.ToText(Date.AddDays(DateTime.LocalNow(), -1), "yyyy-MM-dd"),