Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
mdsajidfaizan
Regular Visitor

manage Power BI Life cycle

Can anyone give me some code reference from where i can use .NET sdk/ Javascript API to perform following task:

 

create workspace collection

Create workspace

create dataset

create new reports

publish reports

create new dashboard

pin items to dashboard

 

same can be updated/deleted.

 

My Requirement is to achive these tasks using pure web application, no windows/console.

 

 

I appreciate your help.

 

Thank you.

7 REPLIES 7
Eric_Zhang
Employee
Employee


@mdsajidfaizan wrote:

Can anyone give me some code reference from where i can use .NET sdk/ Javascript API to perform following task:

 

create workspace collection

Create workspace

create dataset

create new reports

publish reports

create new dashboard

pin items to dashboard

 

same can be updated/deleted.

 

My Requirement is to achive these tasks using pure web application, no windows/console.

 

I appreciate your help.

 

Thank you.


I see "create workspace collection“, so I think you're using Power BI Embedded. In Power BI Embedded, there's no dashboard. For both Power BI service and Power BI Embedded, there're no such REST APIs to create/edit reports, dashboards or tiles. For the rest of your requirement, you can reference this github repo. The ProvisionSample covers most of your requirements.

 

 

Hello Eric,

I thank you for clearing my base. I also understand the limitations of each API/Methods.

But i am not able to perform all my tasks, as i have to use only web application interface in single application, i can't use desktop/console here. I am still working on the console applicaiton sample and trying it to convert into web. Meanwhile if you see any other option to close all my needs, it would be very helpful.

 

I will look forward to get more clarifications/any other work around which suits the business.

 

But microsoft should think once before releasing any API which has limitations, if a developer cant perform certain task for a technology which costs money, it is really an annoying thing.

 

Thank you.


@mdsajidfaizan wrote:

Hello Eric,

I thank you for clearing my base. I also understand the limitations of each API/Methods.

But i am not able to perform all my tasks, as i have to use only web application interface in single application, i can't use desktop/console here. I am still working on the console applicaiton sample and trying it to convert into web. Meanwhile if you see any other option to close all my needs, it would be very helpful.

 

I will look forward to get more clarifications/any other work around which suits the business.

 

But microsoft should think once before releasing any API which has limitations, if a developer cant perform certain task for a technology which costs money, it is really an annoying thing.

 

Thank you.


@mdsajidfaizan

I was inspired by someone in the community and have some new findings here. Actually it is possible to create a report when embeding in your own app. Check below demo. You can actually embedded a report desiner panel in your application. Just copy the code in a .html file and open it in Chrome. See more demos here.

 

<html>

 <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/jquery/dist/jquery.js"></script>

<script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/powerbi-client/dist/powerbi.js"></script>
 
<script type="text/javascript">
window.onload = function () {   
// Read embed application token from textbox
var txtAccessToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXIiOiIwLjIuMCIsInR5cGUiOiJlbWJlZCIsIndjbiI6IlBvd2VyQmlBenVyZVNhbXBsZXMiLCJ3aWQiOiJmODFjMTk2Ni1lZGVlLTQxMWItOGY4YS1mODQ0NjAxOWIwNDQiLCJkaWQiOiIxZWUwYjI2NC1iMjgwLTQzZjEtYmJiNy05ZDhiZDJkMDNhNzgiLCJzY3AiOiJEYXRhc2V0LlJlYWQiLCJpc3MiOiJQb3dlckJJU0RLIiwiYXVkIjoiaHR0cHM6Ly9hbmFseXNpcy53aW5kb3dzLm5ldC9wb3dlcmJpL2FwaSIsImV4cCI6MTk2MTg1NDIzNiwibmJmIjoxNDg4NDY4NjM2fQ.Udv5Y6gMrTKUw0-5mXeCwud8u4JI5Y5loAwJc2jWugQ';
 
// Read embed URL from textbox
var txtEmbedUrl = 'https://embedded.powerbi.com/appTokenReportEmbed';
 
// Read dataset Id from textbox
var txtEmbedDatasetId = '1ee0b264-b280-43f1-bbb7-9d8bd2d03a78';
 
// Embed create configuration used to describe the what and how to create report.
// This object is used when calling powerbi.createReport.
var embedCreateConfiguration = {
    accessToken: txtAccessToken,
    embedUrl: txtEmbedUrl,
    datasetId: txtEmbedDatasetId,
};
 
// Grab the reference to the div HTML element that will host the report
var reportContainer = $('#reportContainer')[0];
 
// Create report
var report = powerbi.createReport(reportContainer, embedCreateConfiguration);
 
// Report.off removes a given event handler if it exists.
report.off("loaded");
 
// Report.on will add an event handler which prints to Log window.
report.on("loaded", function() {
    Log.logText("Loaded");
});
 
report.off("error");
report.on("error", function(event) {
    Log.log(event.detail);
});
 
// report.off removes a given event handler if it exists.
report.off("saved");
report.on("saved", function(event) {
    Log.log(event.detail);
    Log.logText('In order to interact with the new report, create a new token and load the new report');
});

              
 
}
</script>

<div id="reportContainer" ></div>

</html>

 

Anonymous
Not applicable

Hi Eric,

 

I have tried the above html code for creating an Report but no data is getting dispalyed for me I have replaced Access Token,Embedded Url and Datasetid but still no data is getting dispalyed.

 

Please kindly help me on this.

 

 

Thanks

Vannikannan.kScreenshot (37).png

 

Hi,

The coode provided in last thread response is a good sample of a common 'classic' Power BI Embedded: JavaScript - HTML 'report' rendering scenario.

 

If you're looking for samples in JavaScript context you can still have a look at both approaches linked below:

  1. How to Embed and Filter a Power BI Report with the new Power BI Embedded JavaScript API
    http://blog.jongallant.com/2017/01/powerbi-embedded-javascript-api-range-slider-filter/
  2. Integrate a dashboard into an app
    https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-integrate-dashboard/

Before you dive too deep, it's important to make a clear distinction between the two approaches listed above
as Microsoft Team announced significant changes regarding upcoming convergence between the two.
Microsoft Team claimed you'll still be able to use Power BI Embedded for a certain time,
though strongly suggest aiming at second...

 

The first link refers to what I would call the 'classic' Power BI Embedded - Workspace Collection -Workspace model topology
used in a JavaScript-HTML context. I personally found Jon's explanation to be a concise and straight forward explanation from start-to-end.
So you would first need to create a Workspace Collections on Azure Portal account then use PowerBI-CLI interface
a to 'provision' data. Jon gives a clear step-by-step description on how it's done.

 

In the case of second link: Power BI API - Integrate a dashboard into an app
you'll somehow need to go through a different process...

So in order to take advantage of the second Power BI API approach, you will first have to register an application with your Azure Active Directory tenant.
Main reason is, you'll need to do this first so that you have a Client ID and Client Secret that identifies your registered web app in Azure AD.
Without a Client ID and Client Secret, Azure AD cannot authenticate your web application. In the Integrate a dashboard sample, you use the Client ID and Client Secret you get after registration to configure the sample application,
so that the sample can authenticate to Azure AD. In the end, users will be asked to sign on their [ Power BI Pro...] account, after which they'll see a list of available registered dashboards. Clicking on list option element should display the requested dashboard.

 

In the end, the client iFrame rendering process is pretty similar in both cases - as you'll still need to provision same [AccessToken, EmbedUrl, ReportID|DashboardID]
attribute parameters in order to display the adequate content you requested. What mainly changes is where and how you will provide those... 😉


Hope this helps. 

Greg_Deckler
Super User
Super User

https://msdn.microsoft.com/en-us/library/mt147898.aspx


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Hello Smoupre, I visited to this page earlier, it does not have functionalities which i need.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.