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
bato93
New Member

Adding Entra User Group to Power BI Datasource [C# / Power BI SDK]

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:

bato93_0-1724439047153.png

 

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

bato93_1-1724439343562.png

 

Would appreciate any guidance I have already lost days trying to figure it out

2 REPLIES 2
Anonymous
Not applicable

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

lbendlin
Super User
Super User

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 .

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.