Forum Discussion

brmstn's avatar
brmstn
New Member
2 years ago

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