Forum Discussion

Sanjana's avatar
Sanjana
Frequent Visitor
7 years ago
Solved

unable to generate token using the datasetid for reports using effective identity

using (var client = new PowerBIClient(new Uri(API_URL), new TokenCredentials(accessToken, "Bearer"))) { Report powerBiReport = await client.Reports.GetReportInGroupAsync(groupId, reportId.ToString(...
  • Jayendran's avatar
    7 years ago

    Hi Sanjana ,

     

    What do you mean by fails , do you get any error ? pls share that.

     

    • Make sure that username ,roles are not having null values
    • Make sure your reports developed using the RLS
                        if (datasets.IsEffectiveIdentityRolesRequired == true)
                        {
                            if (!string.IsNullOrWhiteSpace(username))
                            {
                                var rls = new EffectiveIdentity { Username = username, Roles = new List<string> { roles }, Datasets = new List<string> { report.DatasetId } };
    
                                if (!string.IsNullOrWhiteSpace(roles))
                                {
                                    var rolesList = new List<string>();
                                    rolesList.AddRange(roles.Split(','));
                                    rls.Roles = rolesList;
                                }
                                // Generate Embed Token with effective identities.
                                generateTokenRequestParameters = new GenerateTokenRequest(accessLevel: "view", identities: new List<EffectiveIdentity> { rls });
                            }
                           
                        }

    Try the above code which having more condition for you to check