Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Rick4him
Helper I
Helper I

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);

 

1 ACCEPTED SOLUTION
Eric_Zhang
Employee
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);

 


@Rick4him

Can you ensure all those options are correct.

  1. The registered application has sufficient permissions.
  2. The groupid is correct.
  3. The master power bi account is the admin of the group.
  4. 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

  1. 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); 
                    }
  2. Test the REST API GenerateToken in POSTMAN.

 

View solution in original post

3 REPLIES 3
Eric_Zhang
Employee
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);

 


@Rick4him

Can you ensure all those options are correct.

  1. The registered application has sufficient permissions.
  2. The groupid is correct.
  3. The master power bi account is the admin of the group.
  4. 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

  1. 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); 
                    }
  2. Test the REST API GenerateToken in POSTMAN.

 

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? 

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.