Forum Discussion

skbg's avatar
skbg
New Member
2 years ago
Solved

400 Bad Request Creating embed token with effective identity requires dataset to be provided

Hi,

I'm migrating client-code from ADAL.NET to MSAL.NET that embeds Power BI report, and what was working under ADAL.Net is failing in MSAL.Net approach. I'm unable to get the access token to a report with effective identity though I'm passing all parameters correctly. The error message 400 bad request with error is very misleading. I cannot find the reason this fails while ADAL.Net code with same parameters still works. I'm passing the SP's object id correctly as in ADAL.Net, but it fails.

Any idea what i'm doing wrong, kindly help.

 

public static async Task<EmbedToken> GetEmbedToken4(Guid workspaceId, Guid reportId, string accessLevel = "view")
{
using (var pbiClient = await GetPowerBiClient())
{
var pbiReport = pbiClient.Reports.GetReportInGroup(workspaceId, reportId);
string dataSet = pbiReport.DatasetId.ToString();
// Generate token request for RDL Report
var generateTokenRequestParameters = new GenerateTokenRequest(
accessLevel: accessLevel,
datasetId: dataSet,
identities: new List<EffectiveIdentity> { new EffectiveIdentity(username: "XyZ", roles: new List<string> { "010dd4a9-a250-4968-979e-4e7bf5b65ba7" })
});
// Generate Embed token
var embedToken = pbiClient.Reports.GenerateTokenInGroup(workspaceId, reportId, generateTokenRequestParameters);

return embedToken;
}

}

 

 

  • Anyone facing this issue, the error message is actually correct.

     

    While passing EffectiveIdentity, you also need to pass the dataset id in the ei list as datasets:, i was missing that.

     

    Hope this helps.

    -skbg

2 Replies

  • skbg's avatar
    skbg
    New Member

    Anyone facing this issue, the error message is actually correct.

     

    While passing EffectiveIdentity, you also need to pass the dataset id in the ei list as datasets:, i was missing that.

     

    Hope this helps.

    -skbg

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi skbg ,

      Whether your problem has been resolved? If yes, could you please mark your post as Answered? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.

      Best Regards