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

Custom Connector Dynamic Parameter In API

I am working on a custom connector and I have finished almost 75% of my work. My question is related to custom user input.

Captain001_0-1683814000801.png

Here is my navigation pane I want to take input from the user on selecting any table from my navigation and then call YourApiFunction.

Here is my code 

section PQExtension1;
Table.ToNavigationTable = (
table as table,
keyColumns as list,
nameColumn as text,
dataColumn as text,
itemKindColumn as text,
itemNameColumn as text,
isLeafColumn as text
) as table =>
let
tableType = Value.Type(table),
newTableType = Type.AddTableKey(tableType, keyColumns, true) meta
[
NavigationTable.NameColumn = nameColumn,
NavigationTable.DataColumn = dataColumn,
NavigationTable.ItemKindColumn = itemKindColumn,
Preview.DelayColumn = itemNameColumn,
NavigationTable.IsLeafColumn = isLeafColumn
],
navigationTable = Value.ReplaceType(table, newTableType)
in
navigationTable;
[DataSource.Kind="PQExtension1", Publish="PQExtension1.Publish"]
//shared PQExtension1.Contents = (authKey as text) =>

shared PQExtension1.Contents = Value.ReplaceType(HelloWorldImpl, HelloWorldType);

HelloWorldImpl = (authKey as text) as table =>

let

url = "https://.../.../spreadsheets",
headers = [ Authorization = "Bearer " & authKey ],
options = [ Headers = headers ],
response = Web.Contents(url, options),
json = Json.Document(response),
items = json[items],
toTable = Table.FromList(items, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
expand = Table.ExpandRecordColumn(toTable, "Column1", {"id", "name", "slug", "folder_id", "created_at"}, {"id", "name", "slug", "folder_id", "created_at"}),

YourApiFunction = (id as text,message as text) as any =>
let
// Parse the JSON response and extract the "items" array
base_url = "https:///.../...//spreadsheets",
url=base_url & "/"&message& "/tables" & "/" & id & "/values/A:ON" ,
headers = [ Authorization = "Bearer " & authKey ],
options = [ Headers = headers ],
response = Web.Contents(url, options),
json = Json.Document(response),
items = json[items],
// Extract the column names from the first array in the "items" array
columnNames = List.First(items),

// Extract the remaining arrays in the "items" array as data
data = List.Skip(items, 1),

// Create a table from the data with the column names
table = Table.FromRows(data, columnNames)
in
table,
convertListToTable = (list as list,message as text) as table =>
let
toTable = Table.FromList(list, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
expand = Table.ExpandRecordColumn(toTable, "Column1", {"id", "name", "slug","created_at","tables"}, {"id", "name", "slug","created_at","tables"}),
ids = expand[id],
apiResponses = List.Transform(ids, (id) => YourApiFunction(id,message)),
combinedTable = Table.Combine(apiResponses)
in
combinedTable,
CreateNavTable = (message as text) as table =>
let
url = url & "/" & message,
response = Web.Contents(url, options),
json = Json.Document(response),
pages = json[pages],
toTable = Table.FromList(pages, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
expand = Table.ExpandRecordColumn(toTable, "Column1", {"id", "name", "slug","created_at","tables"}, {"id", "name", "slug","created_at","tables"}),
addRow = (row) => #table({"Name", "Key", "Data", "ItemKind", "ItemName", "IsLeaf"}, {{row[name],row[id],convertListToTable(row[tables],message), "Item", row[name], true}}),
loop = List.Accumulate(Table.ToRecords(expand), #table({"Name", "Key", "Data", "ItemKind", "ItemName", "IsLeaf"}, {}), (tbl, row) => Table.Combine({tbl, addRow(row)})),
navTable = Table.ToNavigationTable(loop, {"Key"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf")
in
navTable,
addRow = (row) => #table({"Name", "Key", "Data", "ItemKind", "ItemName", "IsLeaf"}, {{row[name],row[id], CreateNavTable(row[id]), "Folder", row[name], false}}),
loop = List.Accumulate(Table.ToRecords(expand), #table({"Name", "Key", "Data", "ItemKind", "ItemName", "IsLeaf"}, {}), (tbl, row) => Table.Combine({tbl, addRow(row)})),
navigationTable = Table.ToNavigationTable(loop, {"Key"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf")
in
navigationTable;

// Data Source Kind description
PQExtension1 = [
Authentication = [
Implicit = [Label = "Rows Connector"]
],
Label = "Rows Connector"
];

 

 

 

 

1 REPLY 1
lbendlin
Super User
Super User

ok. what is your question?

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