Forum Discussion

mdsajidfaizan's avatar
mdsajidfaizan
Regular Visitor
9 years ago

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

    • mdsajidfaizan's avatar
      mdsajidfaizan
      Regular Visitor

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

  • Eric_Zhang's avatar
    Eric_Zhang
    Microsoft 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.

     

     

    • mdsajidfaizan's avatar
      mdsajidfaizan
      Regular Visitor

      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.

      • Eric_Zhang's avatar
        Eric_Zhang
        Microsoft Employee

        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>