GithubHelp home page GithubHelp logo

microsoft / powerbi-csharp Goto Github PK

View Code? Open in Web Editor NEW
634.0 137.0 746.0 32.38 MB

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

Home Page: https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedding/

License: Other

C# 99.85% Batchfile 0.08% PowerShell 0.08%

powerbi-csharp's Introduction

Power BI REST APIs for .NET

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

Install-Package Microsoft.PowerBI.Api

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

...
using (PowerBIClient client = new PowerBIClient(credentials))
{

    Console.WriteLine("\r*** DATASETS ***\r");

    // List of datasets in a workspace
    Datasets datasets = client.Datasets.GetDatasets(groupId);

    foreach(Dataset ds in datasets.Value)
    {
        Console.WriteLine(ds.Id + " | " + ds.Name);
    }

    Console.WriteLine("\r*** REPORTS ***\r");

    // List of reports in a workspace
    Reports reports = client.Reports.GetReports(groupId);

    foreach (Report rpt in reports.Value)
    {
        Console.WriteLine(rpt.Id + " | " + rpt.Name +  " | DatasetID = " + rpt.DatasetId);
    }
}
...

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

...
using (PowerBIClient client = new PowerBIClient(credentials))
{
    // Create a request for getting Embed token
    var tokenRequest = new GenerateTokenRequestV2(datasets: datasets, reports: reports, targetWorkspaces: workspaces, identities: 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.

...
using (PowerBIClient client = new PowerBIClient(credentials))
{
    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

powerbi-csharp's People

Contributors

ali-hamud avatar aliabufoul avatar aluong avatar amoshersch avatar anant-k-singh avatar ayeshurun avatar diklab avatar dowaldma avatar dvana avatar eisuissa avatar eligr avatar gilitaragano avatar gregorybor avatar kesemsharabi avatar laurent-mic avatar mahirdiab avatar marinafusterms avatar mattmazzola avatar mekam14 avatar mshmordo avatar noanu avatar ofirgordon avatar ranbreuer avatar someuser5 avatar t-yoigra avatar tarostok avatar v-trisshores avatar wbreza avatar yoavo avatar zakharborodin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.