Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

PowerBI-CSharp

> 编程语言
Open source

Welcome to the .NET developer community for Power BI. Here you will find resources for the .NET SDKs for Power BI Embedded V2.0.0

759 stars0 likes1 views
WebsiteGitHub

About

Welcome to the .NET developer community for Power BI. Here you will find resources for the .NET SDKs for Power BI Embedded V2.0.0

Power BI REST APIs for .NET

Migration Guide

If you are migrating from version v4.22 to v5, please refer to the Migration Guide for detailed instructions and breaking changes.

Overview

The Power BI REST APIs provide service endpoints for embedding, user resources management, administration and governance.

For more information about Power BI REST APIs, see Power BI REST APIs overview.

Power BI API library

The Microsoft.PowerBI.Api library for .NET enables you to work with Power BI REST APIs in your .NET or NET Core application.

Install the NuGet package directly from the Visual Studio Package Manager console.

Visual Studio Package Manager

powershell
Install-Package Microsoft.PowerBI.Api

Creating the Power BI Client

The PowerBIClient can be created using either credentials or a Microsoft Entra Access Token.

Using Credentials

Authenticate by providing service principal credentials(client ID, client secret, and tenant ID) or username password credentials(client ID, tenant ID, username and password ).

For more details, see the Authentication Updates section in the migration guide.

Using Microsoft Entra Access Token

Alternatively, authenticate using a Microsoft Entra Access Token for secure, delegated access.

Examples

Below are basic examples demonstrating some of the most common capabilities of the SDK. Full examples including authentication are avaliable in PowerBI-Developer-Samples

Get the list of datasets and reports in a Power BI workspace

…

Creating an Embed Token to reports and datasets

Embed tokens are used to provide access to Power BI artifacts like reports and datasets to embed into an application. To create a report embed token you will need a Power BI Embedded capacity, and the Ids of the workspaces and artifacts to provide access to. For more information about Power BI Embedded visit the Power BI Embedded Analytics Playground

csharp
...
using (PowerBIClient client = new PowerBIClient(credentials or Microsoft Entra Access Token))
{
    // Create a request for getting Embed token
     var tokenRequest = new GenerateTokenRequestV2();
     tokenRequest.Datasets.Add(datasets);
     tokenRequest.Reports.Add(reports);
     tokenRequest.TargetWorkspaces.Add(workspaces);
     tokenRequest.Identities.Add(identities);

    // Get Embed token
    var embedToken = client.EmbedToken.GenerateToken(tokenRequest);
}
...

Get Reports As Admin

Returns a list of reports for the organization. The caller must have administrator rights.

csharp
...
using (PowerBIClient client = new PowerBIClient(credentials or Microsoft Entra Access Token))
{
    Console.WriteLine("\r*** REPORTS ***\r");

    // List of reports in the organization.
    AdminReports reports = client.Reports.GetReportsAsAdmin();

    foreach (AdminReport rpt in reports.Value)
    {
        Console.WriteLine(rpt.Id + " | " + rpt.Name);
    }
}
...

Additional links

  • Power BI REST APIs
  • PowerBI-Developer-Samples
  • AAD Application registration
  • Power BI Embedded Analytics Playground
  • PowerBI Powershell CmdLet

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言