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
274188A
Advocate I
Advocate I

Connector

I amd building a custom PBI Desktop connector with the sdk: 

I have these 2 files:


*.pq

 

section MyConnector;

// Define the data source function
MyConnectorImpl = (Url as text, Token as text) as table =>
let
    actualUrl = Url,
    record = [
        token = Token,
        content = "record",
        format = "csv"
    ],
    body = Text.ToBinary(Uri.BuildQueryString(record)),
    options = [
        Headers = [#"Content-type" = "application/x-www-form-urlencoded"],
        Content = body
    ],
    result = Web.Contents(actualUrl, options),
    #"Imported CSV" = Csv.Document(result, [Delimiter = ",", Encoding = 65001, QuoteStyle = QuoteStyle.Csv]),
    #"Promoted Headers" = Table.PromoteHeaders(#"Imported CSV", [PromoteAllScalars = true])
in
    #"Promoted Headers";

// Define the type for the data source function
MyConnectorType = type function (
    Url as text,
    Token as text
) as table;


*.query.pq

[DataSource.Kind="MyConnector", Publish="MyConnector.Publish"]
shared MyConnector.Contents = Value.ReplaceType(MyConnectorImpl, MyConnectorType);

// Data Source UI publishing description
MyConnector.Publish = [
    Beta = true,
    Category = "Other",
    ButtonText = { "My Connector", "My Connector" },
    LearnMoreUrl = "https://example.com"
];

 

 

My Error:
Afer I build, then evaluate the query file, I see the following:


[1:48:56 PM]    [Info]  Detected a newer mez file, about to infer its latest info. 1720763336064, 1536065
[1:48:56 PM]    [Info]  [Task found] c:\Users\xxxx\.vscode\extensions\powerquery.vscode-powerquery-sdk-0.4.0-win32-x64\.nuget\Microsoft.PowerQuery.SdkTools.2.127.3\tools\PQTest.exe info
                --extension "d:\repos\Power Query Extensions\MyConnector\bin\AnyCPU\Debug\MyConnector.mez"
                --prettyPrint
[1:48:57 PM]    [Debug] onModuleLibraryUpdated: []
[1:48:57 PM]    [Info]  Update last ctime of an inferred mez file to 1720763336064
[1:48:57 PM]    [Info]  DisplayExtensionInfo result MyConnector
[1:48:57 PM]    [Info]  [Task found] c:\Users\xxxxxA\.vscode\extensions\powerquery.vscode-powerquery-sdk-0.4.0-win32-x64\.nuget\Microsoft.PowerQuery.SdkTools.2.127.3\tools\PQTest.exe run-test
                --extension "d:\repos\Power Query Extensions\MyConnector\bin\AnyCPU\Debug\MyConnector.mez"
                --queryFile "d:\repos\Power Query Extensions\MyConnector\MyConnector.query.pq"
                --prettyPrint
[1:48:58 PM]    [Info]  RunTestBattery result [
    {
        "ActivityId": "094ca3e3-75c4-4112-b34a-1d4075ca94b3",
        "DataSourceAnalysis": [],
        "Details": "Token ';' expected. Start position: (3, 1). End position (3, 7).",
        "EndTime": "2024-07-12T05:48:58.4633242+00:00",
        "Method": "PQTest.RunTest",
        "Name": "MyConnector.query.pq",
        "StartTime": "2024-07-12T05:48:58.4429286+00:00",
        "DiagnosticEvents": {},
        "RowCount": 0,
        "Status": "Failed",
        "Type": "PQTest.Expression",
        "Error": {
            "Message": "Token ';' expected. Start position: (3, 1). End position (3, 7)."
        }
    }
]


Any incites appreciated

 

- my thoughts are it's something to do with having 2 input parameters - perhaps not being initialsed correctly when this line is called:

shared MyConnector.Contents = Value.ReplaceType(MyConnectorImpl, MyConnectorType);

1 REPLY 1
Anonymous
Not applicable

Hi @274188A ,

You didn't give the complete code, I'm not sure if the content in your brackets is correct, could you provide the complete code?

vjunyantmsft_0-1721009399619.png

Value.ReplaceType - PowerQuery M | Microsoft Learn

Best Regards,
Dino Tao

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.

Top Solution Authors