Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
How can I add a member of group workspace using C# PowerBI API?
I trying to add a email member to my workspace using the power bi api for .NET but i'm receiving a message "Operation returned an invalid status code 'Unauthorized'" and i'm using the owner of the workspace.
I tryied to use
Snippet
client.Groups.AddUserAsAdminAsync(grupo.Id, usuario);
and
Snippet
client.Groups.UpdateGroupAsAdmin(grupo.Id, grupo);
and it's the same message in both cases.
And i need to give this permission automatically to some users get access to the workspace without using my master user.
Regards,
Rafael
Hi @rsaguiar,
Did you have an authentication step in your codes? We need to get the access token before we call the APIs.
Best Regards,
Dale
Yes, my client object call my method GetPowerBIClient before trying to update my group
Snippet
static string GetAccessToken() { AuthenticationContext authContext = new AuthenticationContext(aadAuthorizationEndpoint); var userCredentials = new UserPasswordCredential(pbiUserName, pbiUserPassword); return authContext.AcquireTokenAsync(resourceUriPowerBi, aplicationId, userCredentials).Result.AccessToken; } public static PowerBIClient GetPowerBiClient() { var tokenCredentials = new TokenCredentials(GetAccessToken(), "Bearer"); pwCliente = new PowerBIClient(new Uri(urlPowerBiRestApiRoot), tokenCredentials); return pwCliente; }
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 4 | |
| 3 | |
| 2 | |
| 1 | |
| 1 |