Forum Discussion
Rest API - 90 Day restriction
I have access and connected to a rest API to pull in some sales data. The api is restricted to 90 days worth of data. My question is, how do I configure Power BI to pull in current data while archiving the historical data? OR if that's not possible, how do I configure the data source of the API to adjust the data call by one day?
The call lanuage is: https://website/order_items?time_start=2020-01-20T21:30:13.247Z&time_end=2020-04-15T21:30:13.247Z. In order to keep the current data coming in, I would have to manually adjust the start time and end time. I would like to have this automated, while keeping a track of the previous days data.
18 Replies
- MariuszCommunity Champion
- parry2kSuper User
vwiles84 this M code will create start and end date range and will update daily, just add another column and make api call from the WebURL column and you are good to go.
let MaxDays = 90, EndDate = Date.From(DateTime.LocalNow()), StartDate = Date.AddDays(Date.From(EndDate),1-MaxDays), Source = #table({"StartDate","EndDate"} ,{{StartDate,EndDate}}), #"Changed Type1" = Table.TransformColumnTypes(Source,{{"StartDate", type datetime}, {"EndDate", type datetime}}), #"Added Custom" = Table.AddColumn(#"Changed Type1", "WebURL", each "https://website/order_items?time_start=" & DateTime.ToText([StartDate],"yyyy-MM-dd")&"&time_end="&DateTime.ToText([EndDate], "yyyy-MM-dd"), type text), #"Added Custom1" = Table.AddColumn(#"Added Custom", "WebData", each Web.Contents([WebURL])) in #"Added Custom1"- vwiles84Helper III
Thank you! I will try that and see how it works!
- vwiles84Helper III
What is the best way to call multiple URL strings? I tried editing my Json.documeent(Web.contents(www.apiurl parameter/) with an AND command but it doesn't work. Is there another place to join the api calls?
- parry2kSuper User
vwiles84 did you tried my solution, parameters in that is already part of URL
Ask anything Power BI. Book appointment for a free consultancy at https://www.perytus.com