Data Connector

The Power BI REST API is a data service that allow applications to manage Power BI content, perform admin operations, and embed Power BI content inside custom applications.

The WireBootstrap for Power BI API Data Connector is a WireBootstrap data connector that can talk to Power BI using the Power BI REST APIs. The WireBootstrap for Power BI REST API Data Connector allows lists of meta data such as dashboards and reports to be displayed inside WireBootstrap components other page elements with minimal configuration.

The data connector also serves data to WireBootstrap for Power BI embed components.

Data Source

To use the data connector, create a WireBootstrap data source using the connector's service provider key in the initialization. The service provider key for the WireBootstrap for Power BI REST API Data Connector is pbi.

const source = new wire.data.DataSource("pbi", {
    ...
});

Authentication

For security, the Power BI REST API requires an access token. For details on creating a Power BI access token, visit Access Tokens.

Once created, set the Headers configuration property when creating the data source to use the token with the Bearer authentication type as seen below.

const authToken = "eyJ0e...Agjmg";

const source = new wire.data.DataSource("pbi", {
    Headers: { Authorization: "Bearer " + authToken },
    ...      
});

Service Root

By default, the root URL of the Power BI REST API is located at the following location.

https://api.powerbi.com/v1.0/myorg

To specify a different location, use the ServiceRoot configuration property on the data source.

const source = new wire.data.DataSource("pbi", {
    ServiceRoot: "https://some-other-address",
    ...
});

Service Provider

Service provider specific properties are set on a WireBootstrap data source using the Provider property.

The WireBootstrap for Power BI REST API Data Connector's service provider has one property called groupId. This is the string id of the group or workspace containing the Power BI objects including dashboards and reports for which meta data will be retrieved using the data source.

The groupId value can seen in the browser's URL after opening a Power BI workspace.

https://app.powerbi.com/groups/{groupId}
https://app.powerbi.com/groups/efb178c2-31ec-4753-b4a6-98bbdf6d6300

To create a WireBootstrap data source against the workspace above, specify the groupId property on the Provider configuration object when creating the data source.

const source = new wire.data.DataSource("pbi", {
    ...
    Provider: {
        groupId: "efb178c2-31ec-4753-b4a6-98bbdf6d6300"
    }
});

Queries

Once created, a data source can execute queries against Power BI using the standard table query interface in WireBootstrap. The syntax for querying Power BI is below.

const query = wire.data.select().from([entity])
    [.where().eq([entity], [id])]

For example, to request a list of dashboards, use the dashboards entity.

const query = wire.data.select().from("dashboards");

To request a single dashboard, qualify the query using the dashboard's id. A dashboard's id can be found in the browser's URL after opening the dashboard in Power BI.

https://app.powerbi.com/groups/{groupId}/dashboards/{dashboardId}
https://app.powerbi.com/groups/efb178c2-31ec-4753-b4a6-98bbdf6d6300/dashboards/31f7bc8a-4a63-4ddb-86fb-84ced3ac8836

The query below requests details for the dashboard above.

const query = wire.data.select().from("dashboards")
    .where().eq("dashboards", "31f7bc8a-4a63-4ddb-86fb-84ced3ac8836");

Execute Queries

After creating a query, execute the query in Power BI using the execAsync method on the data source.

const dashboards = await source.execAsync(query);

Last updated