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.
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; }
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
7 | |
6 | |
3 | |
2 | |
2 |