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
nadavfishman
Regular Visitor

Rest Api-Sql Server 2008R2

hey everybody,

is it possible to create real time report's from sql server 2008 r2 with rest api?

 

i cant get my connection to work via rest api-Rest Api.png

 

 

 

thanks in advanceeeeeeeeeeeeeeeeeeeeeeee

3 REPLIES 3
Eric_Zhang
Employee
Employee

@nadavfishman

As per the snapshot, so you are using Power BI Embedded, right?

To push data via REST API, you can

  1. Create a dataset via the API POST Dataset. You'll get the datasetid in the reponse or you can get a specific dataset via API Get Datasets.
  2. Then push data to the created dataset via API POST Add rows.
    https://api.powerbi.com/v1.0/collections/{workspacecollectionName}/workspaces/{workspaceId}/datasets/{DatasetId}/tables/{TableName}/rows
  3. Then embed a report in creation mode with creation token. Create and save your report.
  4. <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 = 'YourCreationTokenHere';

    // Read embed URL from textbox
    var txtEmbedUrl = 'https://embedded.powerbi.com/appTokenReportEmbed';

    // Read dataset Id from textbox
    var txtEmbedDatasetId = 'yourDatasetIDhere';

    // 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>

 

You can keep pushing data following step 2 with data extracted from SQL Server in whatever way after after the report created.

 

@Eric_Zhang

hey eric,thank you for the reply-

I'm able to use any other suggestion you have to create real-time dashboard.

After looking all over the community and over the web ifount that the best solution is via REst API.

Do you have any other suggestions for my scenario?

 

ps-

I must have an Azure profile to get my tokens?

I dont Use any Azure services-ALl my data side is local servers with SQL 2008 R2.

 

 

 

 

 


@nadavfishman wrote:

@Eric_Zhang

hey eric,thank you for the reply-

I'm able to use any other suggestion you have to create real-time dashboard.

After looking all over the community and over the web ifount that the best solution is via REst API.

Do you have any other suggestions for my scenario?

 

ps-

I must have an Azure profile to get my tokens?

I dont Use any Azure services-ALl my data side is local servers with SQL 2008 R2.

 

 


No for streaming dataset. The provided url contains the access security info. 

Capture.PNG

 

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.

Top Solution Authors