Forum Discussion
URL based date dependent data request from server - M-script/Query
What does the error-message say?
Also, please note this passage from the blogpost you've mentioned: " This technique will only work if the url passed to the first parameter of Web.Contents() is valid in itself, is accessible and does not return an error. "
Your URL doesn't look like that.
- Anonymous7 years agoNot applicable
The Error is shown as follows:
Pressing the Error in Search Successful shows:
Expression.Error: We cannot convert the value "08-04-2019 08:21" to the Record type.
Details:
Value = 08-04-2019 08:21
Type = type- Anonymous7 years agoNot applicable
I have now reduced the code to a half working state:
let Now = DateTime.LocalNow(), Yesterday = Date.AddDays(Now, -1), Date = DateTime.ToText(Yesterday, "dd-MM-yyyy hh:mm") , Date2 = DateTime.ToText(Now, "dd-MM-yyyy hh:mm"), Terms = #table({"Dato1"}, {{(Uri.BuildQueryString([StartTimeLocal=Date,EndTimeLocal=Date2]))}}), Source = Csv.Document( Web.Contents( "http://Yoursite.com/data/glovadata/search/csv?", [Query=Terms] ),[Delimiter=";", Columns=23, Encoding=1252, QuoteStyle=QuoteStyle.None] ) in TermsBy running the "in Terms" it is clear that the date dependent urlencoded code generated in Terms is correct and is as it should be.. However, I do not know why it is not merging with the rest of the URL "http://Yoursite.com/data/glovadata/search/csv?", even though the [Query=Terms] is given.
The following Error is displayed when "in Source" is used in the end:
DataSource.Error: Web.Contents failed to retrieve content from 'http://Yoursite.com/data/glovadata/search/csv' (400): Bad Request
Details:
DataSource Kind = Web
DataSourcePath = http: //Yoursite.com/data/glovadata/search/csv
Url = http: //Yoursite.com/data/glovadata/search/csv- ImkeF7 years agoCommunity Champion
You have to adjust your main-URL. See the blogpost you've mentioned:
The query will return values for oranges, although the main URL contains query-parameters for apples.
So you just have to add a hardcoded query-string to your main URL. That will then be overwritten by the values from the Query-record.