Forum Discussion
Rest Api-Sql Server 2008R2
As per the snapshot, so you are using Power BI Embedded, right?
To push data via REST API, you can
- 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.
- 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 - Then embed a report in creation mode with creation token. Create and save your report.
-
<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.
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.
- Eric_Zhang9 years agoMicrosoft Employee
nadavfishman wrote:
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.