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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Help with Custom Connector

Hi All,

 

I am a newbie with Power BI, I'm trying to setup a custom connector but it's being quite a challenge so far, my aim is to first authenticate to the API and then retrieve reports, but I am getting a "The name DataWorldSwagger.Contents wasn't recongnised" error.

 

Here is the code:

query.pq

 

 

 

let
    result = DataWorldSwagger.Contents()
in
    result

 

 

 

 

pq

 

 

 

// This file contains your Data Connector logic
section DataWorldSwagger;

[DataSource.Kind="DataWorldSwagger", Publish="DataWorldSwagger.Publish"]
shared DataWorldSwagger.Contents = () =>
let
   token = TokenMethod(),
   // get reports
   Data2 = Web.Contents("https://xxx:8002/v1/reports",[Headers=[#"Authorization" = "Bearer " & token,#"Content-type" = "application/x-www-form-urlencoded",#"Accept" = "application/json"]]),
   DataRecord = Json.Document(Data2),
   //token = Json.Document(Data)[token],
   Source= DataRecord 
in
   Source;

// Data Source Kind description
DataWorldSwagger = [
TestConnection = (dataSourcePath) => { "DataWorldSwagger.Contents", dataSourcePath },
    Authentication = [
        Anonymous = []
    ],
    Label = Extension.LoadString("DataSourceLabel")
];

// Data Source UI publishing description
DataWorldSwagger.Publish = [
    Beta = true,
    Category = "Other",
    ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },
];


TokenMethod = () =>
let
   // get token
   body = "username=admin&password=xxx",
   Data= Web.Contents("https://xxx:8002/v1/auth/token?app=",[Content=Text.ToBinary(body),Headers=[#"Content-type" = "application/x-www-form-urlencoded",#"Accept" = "application/json"]]),
   //DataRecord = Json.Document(Data),
   token = Json.Document(Data)[token],
   Source= token 
in
   Source;

 

 

 

 

All help is appreciated,

 

Thank you in advance,

0 REPLIES 0

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.