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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
skbg
New Member

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

}

 

 

1 ACCEPTED SOLUTION
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

View solution in original post

2 REPLIES 2
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
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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.