Forum Discussion
Power BI Embed report JavaScript
- 9 years ago
Hi,
You can find all the steps needed to setup the enviroment and start embedding,
in this link- https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedding/
The process for embedding for non power bi users are all in this demo App Owns Data.
To get the Embedded Token, Embed URL and report id, the first step is to get an accesstoken, see code snippet from this HomeController.cs.
var credential = new UserPasswordCredential(Username, Password);
// Authenticate using created credentials
var authenticationContext = new AuthenticationContext(AuthorityUrl);
var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ClientId, credential);
And then
// Create a Power BI Client object. It will be used to call Power BI APIs.
using (var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials))
{
// Get a list of reports.
var reports = await client.Reports.GetReportsInGroupAsync(GroupId);
// Get the first report in the group.
var report = reports.Value.FirstOrDefault();
if (report == null)
{
return View(new EmbedConfig()
{
ErrorMessage = "Group has no reports."
});
}
// Generate Embed Token.
var generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view");
var tokenResponse = await client.Reports.GenerateTokenInGroupAsync(GroupId, report.Id, generateTokenRequestParameters);
if (tokenResponse == null)
{
return View(new EmbedConfig()
{
ErrorMessage = "Failed to generate embed token."
});
}
// Generate Embed Configuration.
var embedConfig = new EmbedConfig()
{
EmbedToken = tokenResponse,
EmbedUrl = report.EmbedUrl,
Id = report.Id
};
Actually, underlying the code calls those POWER BI REST APIs Get Reports and GenerateToken .
Thanks a lot. Need to Be Done in Javascript can you Give me the steps or help out how to create azure and all the thinks by step by step
thanks once again
- nimrod9 years agoResolver II
Hi,
You can find all the steps needed to setup the enviroment and start embedding,
in this link- https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedding/- Ashley10228 years agoFrequent Visitor
Would a PowerBI Pro Trial version work?
Office 365 displays my Power BI account as Free.