Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi everyone,
I am using the Power BI SDK to manage my Power BI environment. I came across a issue that seems impossible to solve, when managing the Datasource through app.powerbi.com I can add a User Group from Entra ID to the connection that I setup but when I try adding a user group using the object id in Entra I get a BadRequest.
I have followed the documentation and tried every possible combination but I always receive BadRequest, the funny part is if I try adding a user email that works. Below are the exmples that I tried:
This one works when adding a email user:
public Task AddDataSourceUserEmail(Gateway gateway, GatewayDatasource datasource, string email)
{
return _powerBiClient.Gateways.AddDatasourceUserAsync(gateway.Id, datasource.Id, new DatasourceUser()
{
EmailAddress = email,
DatasourceAccessRight = DatasourceUserAccessRight.Read
});
}
This is what I got from Network when adding a "Group" to the Datasource through app.powerbi.com which works:
So I tried copying the same format when submitting through Power BI SDK (same object id as above is passed as the identifier):
public Task AddDataSourceUserIdentifier(Gateway gateway, GatewayDatasource datasource, string identifier)
{
return _powerBiClient.Gateways.AddDatasourceUserWithHttpMessagesAsync(gateway.Id, datasource.Id,
new DatasourceUser()
{
PrincipalType = PrincipalType.User,
Identifier = identifier,
DatasourceAccessRight = DatasourceUserAccessRight.Read
});
}
I also tried using:
PrincipalType.Group and PrincipalType.App but none of them work I always get BadRequest with this message in the header:
DMTS_PrincipalsAreInvalidError
I also tried passing the object id as the Email Address in DataSourceUser but every time the same result.
Steps to reproduce the error:
1) Create a connection in Power BI
2) Create a user group in Azure Entra ID
3) Try adding the user group to the connection using the Power BI SDK function AddDatasourceUserWithHttpMessagesAsync
If you do Step 1 and 2 and manually add the user group to the connection through app.powerbi.com it works
Would appreciate any guidance I have already lost days trying to figure it out
Thanks for the reply from lbendlin please allow me to provide another insight:
Hi, @bato93
Has the problem been solved? If it does, share your solution and accept it as a solution that will help other community members who have the same problem as you.
Best Regards,
Leroy Lu
If you have a Pro license you can open a Pro ticket at https://admin.powerplatform.microsoft.com/newsupportticket/powerbi
Otherwise you can raise an issue at https://community.fabric.microsoft.com/t5/Issues/idb-p/Issues .
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
6 | |
6 | |
3 | |
2 | |
2 |
User | Count |
---|---|
5 | |
5 | |
4 | |
4 | |
3 |