Forum Discussion

KNN's avatar
KNN
Regular Visitor
5 years ago

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:

 

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:

Same happens in the Power Query editor:

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

 

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.

No RepliesBe the first to reply