Combination of URL and Changeable Datetime to URL for Powerbi web request
Hi good folks
I am trying to request data from a webservice using the URL. However in the URL there is the DATE section which is encoded. I have so far succeeded to combine the part of the url with startdate and enddate and constructed the code.
However the error I am getting is as follows in the query section (Advanced Editor):
Expression.Error: We cannot convert the value "22-03-2019 12:09" to type Record. Detaljer: Value=22-03-2019 12:09 Type=Type
The code I am using:
Date = DateTime.ToText((DateTime.LocalNow()), "dd-MM-yyyy hh:mm") ,
Date2 = DateTime.ToText((DateTime.LocalNow()), "dd-MM-yyyy hh:mm"),
Kilde = Csv.Document(Web.Contents("http://a website/data/glovadata/search/csv?StartTimeLocal=" + Uri.BuildQueryString(Date) + "&EndTimeLocal=" + Uri.BuildQueryString(Date2)),[Delimiter=";", Columns=23, Encoding=1252, QuoteStyle=QuoteStyle.None])
The first Date must be so i can say -1 day. I tried adding Date.from(datetime........... but didnt end well due to the first error.
It's always a good idea to separate the steps to be able to debug them. You can see that I have Url after in at the end to just evaluate Url and its predecessors. If I know that the Url is correct, I start debuging WebContent and so on.
But the question still remains regarding the "StartTimeLocal=Date". I am still unable to put -x days from todays local date and time. Usually you would say - 1 at the end of ".LocalNow()" or am i wrong?