Skip to main content

Power BI

Needs Votes

Web.Contents () should support scheduled refresh even with dynamic URL

Vote (158) Share
Greg Galloway's profile image

Greg Galloway on 02 Dec 2015 01:58:05

In order for a Power Query data source to be refreshable via scheduled or on-demand refresh inside the Power BI service, the Web.Contents base URL has to be hardcoded. For example, the following is not allowed:
(URL) => Web.Contents(URL)

Only the following is allowed:
Web.Contents("https://bing.com")

(You can pass in dynamic headers or query string parameters.)

I propose that you enable Power Query inside the Power BI service to retrieve dynamic base URLs. Please add a setting where I can authorize a particular Power Query data source to grab any URL. This scenario already works inside Power BI Desktop or Excel in that Power Query can retrieve dynamic URLs after the user sets the auth for each dynamic base URL.

The current workaround is to pass the URL you want to a hardcoded http://YourSiteHere.com/redirect.aspx?url=http://yourdynamicURL.com

But that it not a great workaround.

Comments (10)
Greg Galloway's profile image Profile Picture

af0019aa 9a7e-4776-9021-7b1171cd13bc on 05 Jul 2020 23:32:13

RE: Web.Contents () should support scheduled refresh even with dynamic URL

This is a farce - by now there are several blog posts out from respected authors on how to hack around this arbitrary restriction, so it is a pointless annoyance.

https://blog.crossjoin.co.uk/2016/08/23/web-contents-m-functions-and-dataset-refresh-errors-in-power-bi/

http://blog.datainspirations.com/2018/02/17/dynamic-web-contents-and-power-bi-refresh-errors/

Greg Galloway's profile image Profile Picture

055d40d8 ce8e-4445-b18d-220e7a79fca2 on 05 Jul 2020 23:27:35

RE: Web.Contents () should support scheduled refresh even with dynamic URL

2018 and no response from PowerBI. I get it is a more advanced feature. But we need it soon. I try making this for SharePoint files (because they don't appear in the files list because of the limit).

Greg Galloway's profile image Profile Picture

df6f7e2f c44c-4724-b425-eea319cbf164 on 05 Jul 2020 23:16:06

RE: Web.Contents () should support scheduled refresh even with dynamic URL

Doen't work at all if i need to query same files on different servers in webfarm.Failed

Greg Galloway's profile image Profile Picture

1304f92d 3e44-4bb0-b619-22e22c48f26c on 05 Jul 2020 22:55:46

RE: Web.Contents () should support scheduled refresh even with dynamic URL

Do not work for Web API (using a API Key).
Exemple M :

Web.Contents(
"https://api.foursquare.com/v2/users/self/checkins",
[Query=[
#"limit"= Number.ToText(pagesize),
#"offset"=Number.ToText((page-1)*pagesize),
//#"oauth_token"="***************",
#"v"="20140701"],
ApiKeyName="oauth_token"
])
),

Greg Galloway's profile image Profile Picture

e0114358 39c9-4669-afc7-025e8edb2113 on 05 Jul 2020 22:51:46

RE: Web.Contents () should support scheduled refresh even with dynamic URL

For Web.Content it looks like there is some support for parameters.

If the source is:
Source = Json.Document(Web.Contents("https://data.gov.uk/api/3/action/package_search?q=blah"))

Just add in a Query option with the parameter, like this:
Term = "blah",
Source = Json.Document(Web.Contents("https://data.gov.uk/api/3/action/package_search?q=default", [Query=[q=Term]]))

In our case our API which I'm trying to hit has params as slugs in the URL itself, which does not seem to be supported yet. e.g. https://our-api.com/{term}/data/stuff

Reference:
https://blog.crossjoin.co.uk/2016/08/23/web-contents-m-functions-and-dataset-refresh-errors-in-power-bi/

Web.Contents (Query option):
https://msdn.microsoft.com/en-us/library/mt260892.aspx

Greg Galloway's profile image Profile Picture

47d4e7a7 c4a9-4b18-8351-f3b7773aaa95 on 05 Jul 2020 22:49:31

RE: Web.Contents () should support scheduled refresh even with dynamic URL

Guys, this is absolute deal breaker for less tech savvy users. Cant understand how such mishaps are even possible. I spent hours and hours on building my report in PBI desktop to learn that it will eventually fail in PBI Online. Terrible.

Greg Galloway's profile image Profile Picture

8065ecfd 3605-4ac6-8ccf-580a3fcbc11b on 05 Jul 2020 22:33:38

RE: Web.Contents () should support scheduled refresh even with dynamic URL

This seems to be am important limitation ! And also imortant because of the difference in behaviour between desktop and BI service ... in the desktop these dynamic URL parameters work fine and thenw hen publishing the report the refresh fails...as Microsoft is aiming at putting the desktop and the service on the same level this kind of mismatches should be avoided I think...

Greg Galloway's profile image Profile Picture

4e51c11a ddbf-436f-90cb-2781f41539ad on 05 Jul 2020 22:17:39

RE: Web.Contents () should support scheduled refresh even with dynamic URL

Hi Greg, Could you please advice me more on how you got the URL to work wit the above workaround, I can't seem to get it working. It refreshes on the Power BI desktop when I use dynalic urls but not in the cloud service

Greg Galloway's profile image Profile Picture

4e51c11a ddbf-436f-90cb-2781f41539ad on 05 Jul 2020 22:17:35

RE: Web.Contents () should support scheduled refresh even with dynamic URL

Hi Greg. Could you be more descriptive of the alternate fix you came up woth to refresh dynamic URL. I can't seem to get the above url working

Greg Galloway's profile image Profile Picture

3a421735 e65c-42a0-a282-be4bf40fa7a7 on 05 Jul 2020 22:10:52

RE: Web.Contents () should support scheduled refresh even with dynamic URL

In the meantime, a better warning message that tells you why you can't refresh that Power Query inside the Power BI service would be helpful.