Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I have a problem with refreshing a dataset with a dynamic data source. I get the typical error in the PowerBI Web Service and can't get my code to work around this using the Web.Contents function.
This is my original code, which works finde in Power BI Desktop:
let
BaseUrl = "https://ema.adv.net/external/Sales?%24filter=SalesDateTime%20ge%20"&#"par_SalesDateTime",
Token = par_apikey,
EntitiesPerPage = 1000,
GetJson = (Url) =>
let Options = [Headers=[ #"Authorization" = "Basic " & Token ]],
RawData = Web.Contents(Url, Options),
Json = Json.Document(RawData)
in Json,
GetEntityCount = () =>
let Url = BaseUrl & "&%24count=true&%24top=0",
Json = GetJson(Url),
Count = Json[#"@odata.count"]
in Count,
GetPage = (Index) =>
let Skip = "&%24skip=" & Text.From(Index * EntitiesPerPage),
Top = "&%24top=" & Text.From(EntitiesPerPage),
Url = BaseUrl & Skip & "&" & Top,
Json = GetJson(Url),
Value = Json[#"value"]
in Value
I tried changing the BaseURL, but I ran into errors with authentification as this happens in the GetJson step.
Do you guys see a simple possibility to work around this with RelativePath?
Or should I head to another option like building a flow to refresh it in Power BI Desktop everyday?
Any help would be very appreciated.
Hi @brmstn ,
Have you solved your problem? If you have solved, please share your solution and mark it as an answer.
If not, can you provide a screenshot of any error message that might point to where the problem is?
Please check to see if queries have been added for all dynamic widgets.
Solved: Issues with dynamic token: dynamic data sources ar... - Microsoft Fabric Community
Or you can check whether you will have to change your datset a bit so you can access the network path using on-premises
gateway.
Solved: dynamic data source refresh - Microsoft Fabric Community
And you mentioned that "ran into errors with authentification", please ensure that the credentials for the data source are set up correctly in the Power BI service. If you change the BaseUrl, update the credentials accordingly in the dataset settings.
And maybe these links will help you:
Solved: Dynamic data sources aren't refreshed in the Power... - Microsoft Fabric Community
blog.datainspirations.com/2018/02/17/dynamic-web-contents-and-power-bi-refresh-errors/
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @brmstn
What is the source you are trying to use here? Make sure to check if that is supported in service or not? And to use most of the sources in service you would need a gateway for the same. Check this under your dataset/ semantic model settings.
You can try tweaking your code if the above scenario satisfying. Please also check the previous solved post if that helps.
Solved: Dataset includes dynamic source - wont refresh in ... - Microsoft Fabric Community
let
BaseUrl = "https://ema.adv.net/external/Sales",
Token = par_apikey,
SalesDateTime = DateTime.ToText(par_SalesDateTime, "yyyy-MM-ddThh:mm:ss"),
Url = BaseUrl & "?%24filter=SalesDateTime ge " & SalesDateTime,
Options = [Headers = [#"Authorization" = "Basic " & Token]],
Source = Json.Document(Web.Contents(Url, Options))
in
Source
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
11 | |
8 | |
8 | |
7 |
User | Count |
---|---|
15 | |
13 | |
9 | |
6 | |
6 |