Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago

GenerateToken for dashboard with links to reports in the same workspace

Hello -

I am able to generate token for dashboards that do not have any links embedded just fine, but with anything that has links I get the "InternalServer" error.

var token = new TokenCredentials(accessToken, "Bearer");
using (var client = new PowerBIClient(new Uri("https://api.powerbi.com"), token))
{
ODataResponseListDashboard dashboards = client.Dashboards.GetDashboardsInGroup(groupId);
GenerateTokenRequest request = new GenerateTokenRequest("view");
Dashboard dashboard = dashboards.Value.FirstOrDefault(a => a.DisplayName.Contains("Test"));
try
{
EmbedToken embedToken = client.Dashboards.GenerateTokenInGroup(groupId, dashboard.Id, request);
}
catch (Exception ex1)
{
}
}

Any help would be appreciated.

Thanks, Shilpi

5 Replies

  • Eric_Zhang's avatar
    Eric_Zhang
    Icon for Microsoft Employee rankMicrosoft Employee

    Anonymous wrote:

    Hello -

    I am able to generate token for dashboards that do not have any links embedded just fine, but with anything that has links I get the "InternalServer" error.

    var token = new TokenCredentials(accessToken, "Bearer");
    using (var client = new PowerBIClient(new Uri("https://api.powerbi.com"), token))
    {
    ODataResponseListDashboard dashboards = client.Dashboards.GetDashboardsInGroup(groupId);
    GenerateTokenRequest request = new GenerateTokenRequest("view");
    Dashboard dashboard = dashboards.Value.FirstOrDefault(a => a.DisplayName.Contains("Test"));
    try
    {
    EmbedToken embedToken = client.Dashboards.GenerateTokenInGroup(groupId, dashboard.Id, request);
    }
    catch (Exception ex1)
    {
    }
    }

    Any help would be appreciated.

    Thanks, Shilpi


    Anonymous

    The code works in my test, I don't get any error when trying to generate embed token for a dashboard with tiles having link to a report in the current workspace.

     

    For those specific dashboards that lead to the internal server errors in your case, instead of the C# code, can you try to test the REST API GenerateToken with some test tool, like POSTMAN.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks Eric_Zhang, I will try that.

       

      Are there any spcial permissions needed for those reports/dashboards?

       

      Thanks, Shilpi

      • Anonymous's avatar
        Anonymous
        Not applicable

        Also when I see the picture that you have attached, I realized that when you added the link to your report, the report appeared in the screenshot, where as I see this on my dashboard..