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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
leemat
New Member

Dynamic DataSource - Cannot find issue with code

Trying to get this datasource to refresh online, but am getting the dynamic datasource issue.

I've replaced the dynamic elements in the Web.Contents queries using relativepath, but am still getting the error. Any Ideas?

 

let
    
    // API Credentials
    oauthSite = "https://<REDACTED>.docebosaas.com",
    oauthEndpoint = "/oauth2/token",
    clientId = "<REDACTED>",
    clientSecret = "<REDACTED>",

    // User Credentials
    email = "<REDACTED>",
    pwd = "<REDACTED>",

    // Assemble Token URL
    tokenURL = "client_id=" & clientId & "&" & "client_secret=" & clientSecret & "&" & "grant_type=password&scope=api&username=" & email & "&" & "password=" & pwd,
    binaryTokenURL = Text.ToBinary(tokenURL),
    
    // Call for Token
    tokenData = Json.Document(Web.Contents("https://<REDACTED>.docebosaas.com/oauth2/token", [Headers = [#"Content-Type"="application/x-www-form-urlencoded"], Content=binaryTokenURL])),
    
    // Extract the token from the returned table
    token = tokenData[access_token],
    ver = "/analytics/v1/",
    page = "reports/",
    idReport = "2b5d6a72-0a66-43ef-9b68-70742e03e569/",
    csv = "export/csv",
    endPoint = oauthSite & ver & page & idReport & csv,
    
    
    // Retrieve Execution ID using Token
    Source = Json.Document(Web.Contents("https://<REDACTED>.docebosaas.com/analytics/v1/reports/2b5d6a72-0a66-43ef-9b68-70742e03e569/export/csv", [Headers=[Authorization="Bearer " & token, Accept="application/json"]])),
    data0 = Source[data],
    executionId = data0[executionId],
    endpoint2 = oauthSite & ver & page & idReport & "exports/" & executionId & "/results" & "?pageSize=1000",
    

    // Retrieve Paginated Data
    GetPages = (url as text, nxtToken as text) =>
    let
       GetPageData = (url as text, nxtToken as text) =>
            let 
                SourceGet = Json.Document(Web.Contents(url , [RelativePath = executionId & "/results" & "?pageSize=1000" & nxtToken, Headers=[Authorization="Bearer " & token, Accept="application/json"]])),
                dataGet = try SourceGet[data] otherwise null,
                nextTokenGet = try SourceGet[nextToken] otherwise null,    
                Encoded = try Uri.EscapeDataString(nextTokenGet) otherwise null     
               
            in
                           
                [Data = dataGet, NextToken = Encoded],
        initialData = GetPageData(url, nxtToken),
       accumulatedData = List.Generate(
           () => initialData,
            each [NextToken] <> null,
            each GetPageData(url , "&nextToken=" & [NextToken]),
            each [Data]
            
        ),
        result = List.Combine(accumulatedData)
    in
        result,
    
    GetPagesDelay = (url as text, nxtToken as text) => Function.InvokeAfter(() => GetPages(url, nxtToken), #duration(0, 0, 0, 15)),
    DataSet = GetPagesDelay("https://<REDACTED>.docebosaas.com/analytics/v1/reports/2b5d6a72-0a66-43ef-9b68-70742e03e569/exports/",""),

in
    DataSet

 

 

1 REPLY 1
lbendlin
Super User
Super User

[RelativePath = executionId & "/results" & "?pageSize=1000" & nxtToken, Headers=[Authorization="Bearer " & token, Accept="application/json"]]))

pageSize needs to go into the Query attribute, not RelativePath.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Kudoed Authors