Forum Discussion
URL based date dependent data request from server - M-script/Query
So have you tried it in a different workspace?
Your query returns this error for me in Desktop, so it doesn't make any sense to run this in the service I believe:
Just recognized now that you've skipped the query-parameter. That's probably not a good idea. Please check this article for further details and ideas: http://blog.datainspirations.com/2018/02/17/dynamic-web-contents-and-power-bi-refresh-errors/
- Anonymous7 years agoNot applicable
I would be glad if you pointed out in the code what is wrong and what is right. Because I have tried with Query and without Query parameters and in both situations I either get it working in Dekstop buy not web (or partially in web) or I get it working in desktop only.
I have tried every possible method and combination, but it seems the published report cannot work in autorefresh system. However, if you have a piece of code that seems to be working, I wonder if you would be kind to share ? thanks
- ImkeF7 years agoCommunity Champion
Edited answer:
Sorry, I cannot test if any of this is working, as non of the URL you've posted so far, returns any result for me.
But with regards to the general syntax, I suggest to start small and simply try to fetch a result from the page. You can then parse/transform the returned binary in additional steps.
Either so:
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"), Output = Web.Contents( "http://Yoursite.com/data/glovadata/search/csv?StartTimeLocal=11-04-2019 08:25&EndTimeLocal=12-04-2019 08:25", [Query=[StartTimeLocal=Date, EndTimeLocal=Date2]] ) in Outputor maybe so:
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"), Output = Web.Contents( "https://yoursite.com/data/glovadata/search/csv?StartTimeLocal=11-04-2019%2008:25&EndTimeLocal=12-04-2019%2008:25", [Query=[StartTimeLocal=Date, EndTimeLocal=Date2]] ) in OutputPasting the URL that currently works for you from the browser to the first function parameter should do the job.
Point is to provide a valid fully hardoced URL with query parameters in the main call and to give the query parameters that should actually be used in the Query-record. This will then overwrite the hardcoded part.
- ImkeF7 years agoCommunity Champion
Anonymous , I have edited my answer above.
- Anonymous7 years agoNot applicable
Thank you for the input.
However, using your code, I get to load data the same way as previous codes on desktop. However when published, I get the option to choose legitimations just like before, however the short url is displayed:
"webside" and thus it returns error 400 or or 404. It doesnt return error if you choose a Niveau for security to none or any other. But instead it keeps spinning (as loading) and nothing happens.please give it a go and test it yourself.
thank you
- ImkeF7 years agoCommunity Champion
Not working for me, unfortunately:
- Anonymous7 years agoNot applicable
That is because you URL is not correct.
The produced URL contains simicolons ( : ) , which it shouldn't as URL encode does not use simicolons.
must be something like this: StartTimeLocal=12-04-2019%2002%3A12&EndTimeLocal=13-04-2019%2002%3A12
- ImkeF7 years agoCommunity Champion
Sorry, but I'm out here. Hope that someone else picks this up (otherwise you might consider opening a new thread)
This code isn't working either:
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"), Output = Web.Contents( "http://xxxxx/search/csv?StartTimeLocal=12-04-2019%2002%3A12&EndTimeLocal=13-04-2019%2002%3A12", [Query=[StartTimeLocal=Date, EndTimeLocal=Date2]] ) in Output