Forum Discussion
Invalid Status Code Forbidden after client.Dashboards.GenerateTokenInGroupAsync
Dashboard that I wanted was in the call directly before, then it errors...
var dashboards = await client.Dashboards.GetDashboardsInGroupAsync(GroupId);
// Get the first report in the group.
var dashboard = dashboards.Value.FirstOrDefault();
if (dashboard == null)
{
return View(new EmbedConfig()
{
ErrorMessage = "Group has no dashboards."
});
}
// Generate Embed Token.
var generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view");
var tokenResponse = await client.Dashboards.GenerateTokenInGroupAsync(GroupId, dashboard.Id, generateTokenRequestParameters);
Rick4him wrote:
Dashboard that I wanted was in the call directly before, then it errors...
var dashboards = await client.Dashboards.GetDashboardsInGroupAsync(GroupId);
// Get the first report in the group.
var dashboard = dashboards.Value.FirstOrDefault();
if (dashboard == null)
{
return View(new EmbedConfig()
{
ErrorMessage = "Group has no dashboards."
});
}
// Generate Embed Token.
var generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view");
var tokenResponse = await client.Dashboards.GenerateTokenInGroupAsync(GroupId, dashboard.Id, generateTokenRequestParameters);
Can you ensure all those options are correct.
- The registered application has sufficient permissions.
- The groupid is correct.
- The master power bi account is the admin of the group.
- Is the embedding capacity disable for that specific workspace? You can find the information by clicking "Admin portal"->"Tenant settings"->"Developer settings"(scroll to bottom).
For further troubleshooting. follow
- Add try catch block to your code to get the very specific error message.
try { //your code here } catch (HttpOperationException ex) { //Bad Request var content = ex.Response.Content; Console.WriteLine(content); } - Test the REST API GenerateToken in POSTMAN.
3 Replies
- Eric_ZhangMicrosoft Employee
Rick4him wrote:
Dashboard that I wanted was in the call directly before, then it errors...
var dashboards = await client.Dashboards.GetDashboardsInGroupAsync(GroupId);
// Get the first report in the group.
var dashboard = dashboards.Value.FirstOrDefault();
if (dashboard == null)
{
return View(new EmbedConfig()
{
ErrorMessage = "Group has no dashboards."
});
}
// Generate Embed Token.
var generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view");
var tokenResponse = await client.Dashboards.GenerateTokenInGroupAsync(GroupId, dashboard.Id, generateTokenRequestParameters);
Can you ensure all those options are correct.
- The registered application has sufficient permissions.
- The groupid is correct.
- The master power bi account is the admin of the group.
- Is the embedding capacity disable for that specific workspace? You can find the information by clicking "Admin portal"->"Tenant settings"->"Developer settings"(scroll to bottom).
For further troubleshooting. follow
- Add try catch block to your code to get the very specific error message.
try { //your code here } catch (HttpOperationException ex) { //Bad Request var content = ex.Response.Content; Console.WriteLine(content); } - Test the REST API GenerateToken in POSTMAN.
- Rick4himHelper I
Thank you, I thought I had completed the permissions correctly, but I had not. After the permissions were set following the instructions on the link, the dashboard and the report both rendered via embedding, much appreciated. Rick
- MikeWise1618Frequent Visitor
I am getting the same error, and wanted to check if the embedding capability was disabled per your instructions, but when I go to the Admin Portal there is no "Tenant Settings", there is only a single entry "Capacity Settings".
Has something changed?