The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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; }