> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft Power BI

> Client-mode REST API connector for Power BI push-dataset PostRows, dataset refresh, and real-time streaming push URL — MQTT into Power BI tiles

Technical Preview

## Overview

A client-mode connector for a **curated** slice of the [Power BI REST API](https://learn.microsoft.com/en-us/rest/api/power-bi/) focused on IIoT / edge telemetry into dashboards:

| Catalog connector event | Entity / path | Notes |
| - | - | - |
| POST datasets/\{id}/tables/\{t}/rows | `POST /v1.0/myorg/datasets/{id}/tables/{t}/rows` | Authenticated push dataset; body `{"rows":[...]}` |
| POST datasets/\{id}/refreshes | `POST /v1.0/myorg/datasets/{id}/refreshes` | Trigger refresh; optional `notifyOption`; expect **202** |
| POST streaming push URL | `POST /beta/myorg/datasets/{id}/rows?key=` | Classic real-time streaming; **no** Bearer; body JSON **array** |
| (supporting) push\_path | `POST {push_path}` | Path+query from a full push URL under same host |
| (supporting) GET datasets | `GET /v1.0/myorg/datasets` | List My workspace datasets |
| (supporting) GET refreshes | `GET /v1.0/myorg/datasets/{id}/refreshes?$top=` | Refresh history |
| (supporting) DELETE rows | `DELETE /v1.0/myorg/datasets/{id}/tables/{t}/rows` | Clear push-dataset table |

Default `BASE_ADDRESS` is `https://api.powerbi.com` (no trailing slash). Topics use `analytics/powerbi/<object>/<verb>`.

See the base guide: [REST API Connectors](/latest/lot-language/routes/rest-api-routes).

> [!NOTE]
>
> **Auth (v1.0):** `Authorization: Bearer &lt;Entra access token&gt;`. Prefer Hub secrets (`GET SECRET "POWER_BI_ACCESS_TOKEN"` / `"AZURE_AD_ACCESS_TOKEN"`). Service principals need workspace access and Power BI API permissions (e.g. `Dataset.ReadWrite.All` / `.default`).

> [!NOTE]
>
> **Streaming push URL:** the Power BI service issues a full URL with an embedded `key` query param. Keep `BASE_ADDRESS` as `https://api.powerbi.com` and use `PostStreamingPush` (`dataset_id` + `push_key`) or `PostStreamingPushPath` (`push_path` = path+query). Do **not** send a Bearer header on those events.

> [!NOTE]
>
> Factory live smoke is **blocked** until an Entra token (and preferably a push dataset or streaming push key) is supplied. Point secrets / MQTT JSON at your workspace before production use.

## Basic Syntax

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
# Coreflux REST_API template — Microsoft Power BI
# Auth: Authorization Bearer {value.json.api_token} (v1.0); streaming push key needs none
# BASE_ADDRESS: https://api.powerbi.com

DEFINE ROUTE MicrosoftPowerBiRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://api.powerbi.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT PostRows
        WITH SOURCE_TOPIC "analytics/powerbi/datasets/rows/post"
        WITH DESTINATION_TOPIC "analytics/powerbi/datasets/rows/post/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/v1.0/myorg/datasets/{value.json.dataset_id}/tables/{value.json.table_name}/rows"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
        WITH BODY "{payload}"
    ADD EVENT RefreshDataset
        WITH SOURCE_TOPIC "analytics/powerbi/datasets/refreshes/post"
        WITH DESTINATION_TOPIC "analytics/powerbi/datasets/refreshes/post/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/v1.0/myorg/datasets/{value.json.dataset_id}/refreshes"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "Bearer {value.json.api_token}"
        WITH BODY "{payload}"
    ADD EVENT PostStreamingPush
        WITH SOURCE_TOPIC "analytics/powerbi/streaming/rows/post"
        WITH DESTINATION_TOPIC "analytics/powerbi/streaming/rows/post/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/beta/myorg/datasets/{value.json.dataset_id}/rows?key={value.json.push_key}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
        WITH BODY "{payload}"
```

Full deployable file: `MicrosoftPowerBiRestApi.lot` in the factory package (no `ADD METADATA`).

## Topics

| Event | Source topic | Destination topic |
| - | - | - |
| PostRows | `analytics/powerbi/datasets/rows/post` | `…/response` |
| RefreshDataset | `analytics/powerbi/datasets/refreshes/post` | `…/response` |
| PostStreamingPush | `analytics/powerbi/streaming/rows/post` | `…/response` |
| PostStreamingPushPath | `analytics/powerbi/streaming/push-url/post` | `…/response` |
| GetDatasets | `analytics/powerbi/datasets/list` | `…/response` |
| GetRefreshHistory | `analytics/powerbi/datasets/refreshes/list` | `…/response` |
| DeleteRows | `analytics/powerbi/datasets/rows/delete` | `…/response` |

## Configuration

1. Set `BASE_ADDRESS` to `https://api.powerbi.com`.
2. Store an Entra access token in Hub secrets; map into MQTT `api_token` for v1.0 events.
3. For push datasets: create the dataset/table schema via the Power BI API, then PostRows / DeleteRows.
4. For real-time streaming: create a streaming dataset in the Power BI service, copy the push URL, and use `dataset_id` + `push_key` (or `push_path`).
5. For import datasets: use RefreshDataset (push PostRows does not apply).

## References

* [Power BI REST API](https://learn.microsoft.com/en-us/rest/api/power-bi/)
* [Push datasets — PostRows](https://learn.microsoft.com/en-us/rest/api/power-bi/push-datasets/datasets-post-rows)
* [Refresh dataset](https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/refresh-dataset)
* [Get refresh history](https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/get-refresh-history)
* [Real-time streaming in Power BI](https://learn.microsoft.com/en-us/power-bi/connect-data/service-real-time-streaming)
* [Embed with service principal](https://learn.microsoft.com/en-us/power-bi/developer/embedded/embed-service-principal)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.