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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
KNN
Regular Visitor

Custom Connector: Navigation table Preview fails for all items except one

Hi, 

 

I am building a custom connector that exposes data retrieved from several REST endpoints.

I am using Key authentication. Based on the access key provided I am issing bearer token to be used in all subsequent API request. 

 

When I run the connector in Vusual Studio it works fine, but when I use the connector in Power BI it behaves strange. 

When I enter the requred Key on the first screen Power BI renderes the Entities correctly:

KNN_1-1608215441273.png

 

When I click on the Datacenter Table the data is previewed corectly, but when I click all of the other entities looks like something failes and instead of preview I get the authentication screen again:

KNN_2-1608215554582.png

Same happens in the Power Query editor:

KNN_3-1608217038283.png

Only one query works, the others say: We could't authenticate 

KNN_5-1608217118591.png

 

However if I click cancel and then select this entity and Load the data it loads correctly in Power BI, the refresh works fine. 

I thoght there might be slighit behavior difference when the code is consumed by this Navigator dialog to select which tables to be added in the model. I research a bit how I could debug it but without any luck so far. 

If I return just 

Does someone had similar issue?

Is there a way to see at which point in the chain of steps it fails? Any logs?

 

Here is the sceleton of my code:

 

[DataSource.Kind="Connector", Publish="Connector.Publish"]
shared Connector.Contents = () =>
    let
        accessKey = Extension.CurrentCredential()[Key],

        apiServerUrl = Connector.ParseApiServerUrl(accessKey),

        token = Connector.GetAccessToken(apiServerUrl, accessKey),
        
        dcs = Connector.GetDatacenters(token, apiServerUrl),

        apiKeys = Table.SelectColumns(dcs, {"ApiKey"}),
        
        dailyActivity = Connector.DailyActivity(token, apiServerUrl, apiKeys),
        personas = Connector.Personas(token, apiServerUrl, apiKeys),
        personaStats = Connector.PersonaStatistics(token, apiServerUrl, apiKeys),

        base = #table(type table [ Name = Text.Type, Data = Table.Type, IsLeaf=Logical.Type ], 
        {
            { "Datacenters", dcs, true },
            { "DailyActivity", dailyActivity, true },
            { "Personas", personas, true },
            { "PersonaStatisitcs", personaStats, true }
        }),

        nav = CreateNavTable(base)
    in
        nav;

 

Inside the functions that retrieve the data I am doing N API calls by invoking another functioni per each raw in the following way:

 

Connector.GetStatistics_AllDCs = (token, apiServerUrl, apiKeys, endpoint) => 
    let 
        convs = Table.AddColumn(apiKeys, "PerDC", each Connector.GetStatistics(token, apiServerUrl, endpoint, [ApiKey])),
        forAllDCs = Table.ExpandTableColumn(convs, "PerDC", {"Column1"}, {"Column1"}),
        filtered = Table.SelectRows(forAllDCs, each [Column1] <> null)       
    in
        filtered;

 

The Connector.GetStatistics uses Web.Contents to retrieve the data. 

 

Thanks.

0 REPLIES 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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