To push new data into an existing Power BI dataset using the Power BI REST API from Power BI Desktop, it is important to carefully manage authentication, API setup, and the dataset structure. Following are instructions on how to carry this out:
1. Use Power BI Push Dataset API
In Power BI, the data is allowed to be pushed to streaming or push datasets but not to regular imported datasets. The following are the important API endpoints:
Create Dataset:
POST https://api.powerbi.com/v1.0/myorg/datasets
Define the dataset schema in the request body.
POST https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/tables/{tableName}/rows
- Replace {datasetId} and {tableName} with actual values.
- Send JSON data containing new rows.
Delete all rows (if needed):
DELETE https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/tables/{tableName}/rows
2. Authentication & Token Generation
- Use Azure AD OAuth2 to authenticate.
- Generate an access token and pass it in the API request:
Authorization: Bearer {access_token}
Content-Type: application/json
While using the Azure AD app, make sure that it has permissions for Dataset.ReadWrite.All and Workspace.ReadWrite.All set. Next, here are some good practices and considerations for your Azure AD App-
Establish a streaming dataset for real-time updates. Avoid huge batch updates by pushing small incremental updates. Automate the push of data using Python, PowerShell, or the new Power Automate.