Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join 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.

Reply
brmstn
New Member

Can not refresh in Power BI Service due dynamic data source - how to use Web.Contents/RelativePath?

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.

2 REPLIES 2
Anonymous
Not applicable

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.

AnkitKukreja
Super User
Super User

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

 

 

 

For Power BI trainings or support dm or reach out to me on LinkedIn.
If my response has successfully addressed your question or concern, I kindly request that you mark this post as resolved. Additionally, if you found my assistance helpful, a thumbs-up would be greatly appreciated.

Thanks,
Ankit Kukreja
www.linkedin.com/in/ankit-kukreja1904

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.