Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello everyone,
I am trying to share a workspace with a user outside my organization by using PowerBI .NET SDK (C#).
I am using the following code:
Invitation invitation = new Invitation{
InvitedUserEmailAddress = "username@tenant.onmicrosoft.com",
InviteRedirectUrl = "<url>",
SendInvitationMessage = true,
};
var res = await graphClient.Invitations.Request().AddAsync(invitation);
GroupUser gu = new GroupUser("Viewer", "username@tenant.onmicrosoft.com", null, "username@tenant.onmicrosoft.com", PrincipalType.User);
await client.Groups.AddGroupUserAsync(Guid.Parse(<workspace_id>), gu);
No errors are thrown from this code and the guest user DOES appear in the admin portal as well as in the "access" pane of the workspace.
However, the problem is that the user this workspace is shared with (username@tenant.onmicrosoft.com) is not able to see the workspace or the reports inside the workspace. If the same process is done through the UI it works perfectly.
Has anyone had the same problem?
Regards,
Arber
Solved! Go to Solution.
Hello all,
In case someone else is looking for a solution to this problem:
When inviting a guest user with e-mail address: username@tenant.onmicrosoft.com, their username in the new new tenant will be:
username_tenant.onmicrosoft.com#EXT#@newtenant@onmicrosoft.com and this username has to be used when creating a GroupUser object. (newtenant is the tenant from where the workspace was shared). So the code becomes:
Invitation invitation = new Invitation{
InvitedUserEmailAddress = "username@tenant.onmicrosoft.com",
InviteRedirectUrl = "<url>",
SendInvitationMessage = true,
};
var res = await graphClient.Invitations.Request().AddAsync(invitation);
GroupUser gu = new GroupUser("Viewer", "username_tenant.onmicrosoft.com#EXT#@newtenant.onmicrosoft.com", null, "username_tenant.onmicrosoft.com#EXT#@newtenant.onmicrosoft.com", PrincipalType.User);
await client.Groups.AddGroupUserAsync(Guid.Parse(<workspace_id>), gu);
Hope this helps anyone else!
Regards,
Arber
Hello all,
In case someone else is looking for a solution to this problem:
When inviting a guest user with e-mail address: username@tenant.onmicrosoft.com, their username in the new new tenant will be:
username_tenant.onmicrosoft.com#EXT#@newtenant@onmicrosoft.com and this username has to be used when creating a GroupUser object. (newtenant is the tenant from where the workspace was shared). So the code becomes:
Invitation invitation = new Invitation{
InvitedUserEmailAddress = "username@tenant.onmicrosoft.com",
InviteRedirectUrl = "<url>",
SendInvitationMessage = true,
};
var res = await graphClient.Invitations.Request().AddAsync(invitation);
GroupUser gu = new GroupUser("Viewer", "username_tenant.onmicrosoft.com#EXT#@newtenant.onmicrosoft.com", null, "username_tenant.onmicrosoft.com#EXT#@newtenant.onmicrosoft.com", PrincipalType.User);
await client.Groups.AddGroupUserAsync(Guid.Parse(<workspace_id>), gu);
Hope this helps anyone else!
Regards,
Arber
I wonder if this "How to" in Microsoft docs would help?
https://docs.microsoft.com/en-us/power-bi/admin/service-admin-azure-ad-b2b
Hello Scott,
Thank you for your reply!
The "How to" you shared describes how the sharing is done through the user interface and I can confirm that it works as expected. The problem is that when I try to perform the same steps through the REST API it doesn't work.
Regards,
Arber
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
56 | |
30 | |
23 | |
23 | |
21 |
User | Count |
---|---|
58 | |
41 | |
24 | |
23 | |
23 |