Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Shree007
Frequent Visitor

Error assigning premium capacity to workspace - PowerBINotAuthorizedException

Hi all, 

 

I am encountering an error while attempting to assign premium capacity to the workspace in Power BI. I am using a service principal admin app with Python and REST API to create the workspace and then assign the capacity. However, when I try to assign the workspace, I receive the following error message:

 

{"error":{"code":"PowerBINotAuthorizedException","pbi.error":{"code":"PowerBINotAuthorizedException","parameters":{},"details":[],"exceptionCulprit":1}}}.

 

I have already checked that I have the "Capacity.Readwrite.All" and "Workspace.ReadWrite.All" API permission, and the workspace is successfully created when I run the python script.

 

I suspect that there might be additional steps or permissions required to assign the workspace to the capacity. Any help or guidance on resolving this issue would be greatly appreciated.

 

Thank you 

 

Regards,

Shreenath 

 

@lbendlin @Greg_Deckler @Kaviraj11 @dm-p

Need Help guys

1 ACCEPTED SOLUTION
Shree007
Frequent Visitor

@Greg_Deckler @Anonymous : Thank you all for the response. I have successfully resolved the issue by ensuring that the premium capacity had the necessary contributor permissions. After doing so, my Python code was able to assign the capacity. I would like to express my thank you to you both. 

 

Screenshot attached here : 

Shree007_1-1723811353980.png

 

To assign the necessary permissions, go to Power BI Admin, navigate to Capacity, and select the Premium Capacity and then go to the Contributor option. In this step, make sure to specify the correct security group name, as we had security groups in place..

 

In the future, if anyone works with a Service Principal Admin, I would recommend considering this parameter as well.

 

Thank you! 

View solution in original post

11 REPLIES 11
Shree007
Frequent Visitor

@Greg_Deckler @Anonymous : Thank you all for the response. I have successfully resolved the issue by ensuring that the premium capacity had the necessary contributor permissions. After doing so, my Python code was able to assign the capacity. I would like to express my thank you to you both. 

 

Screenshot attached here : 

Shree007_1-1723811353980.png

 

To assign the necessary permissions, go to Power BI Admin, navigate to Capacity, and select the Premium Capacity and then go to the Contributor option. In this step, make sure to specify the correct security group name, as we had security groups in place..

 

In the future, if anyone works with a Service Principal Admin, I would recommend considering this parameter as well.

 

Thank you! 

Shree007
Frequent Visitor

Yes I can but in my code im using service principle to assign capacity.  This service principle has Capacity.Readwrite.All and Workspace.Readwrite.all API Permission and also it has been added to admin Security Groups. Im able to create Workspace using this service principle but not assign capacity. 

 It seems from this that there is an a Capacity Assignment permission. It also specifies to use the service principal object ID: Move your Power BI embedded analytics app to production - Power BI | Microsoft Learn


Assign a workspace to a capacity by using a service principal
To assign a workspace to a capacity by using a service principal, use the Power BI REST API. When you're using the Power BI REST APIs, make sure to use the service principal object ID. The service principal should have administrator permissions for the workspace and capacity assignment permissions for the capacity.

 

@Shree007



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler 

Thanks for your reply. I am using REST API to create workspace and assign capacities. As you have mentioned I have already added the service principal to my workspace (as admin). Regarding the service principal having permissions to assign capacity or not, how can I check this ? Where can I assign this permission ?

Thanks

@Shree007 These are the instructions found here: Manage your Fabric capacity - Microsoft Fabric | Microsoft Learn

 

To add or remove admins in a Fabric capacity, follow these steps:

  1. In the Capacity settings page, select Fabric Capacity.

  2. From the list of capacities, select the capacity you want to make changes to.

  3. In the capacity's setting page, from the Details tab, select expand Admin permissions.

  4. Add or remove admins from the text box.

  5. Select Apply.

To add or remove admins in a Power BI Premium capacity, follow these steps:

  1. In the Capacity settings page, select Power BI Premium.

  2. From the list of capacities, select the capacity you want to make changes to.

  3. In the capacity's setting page, from the Details tab, select expand Admin permissions.

  4. Add or remove admins from the text box.

  5. Select Apply.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Hi, 

 

We have PowerBi Premium Capacity and I tried to add, but i'm unable to add a ServicePrinciple or a Security Group in there. looks like it works only for individual users. Do you know how to add a ServicePrinciple ? 

 

Thanks in advance.

 

 

Anonymous
Not applicable

Thanks for the reply from Greg_Deckler , please allow me to provide another insight:

Hi, @Shree007 

Regarding adding a service principal to a workspace, my solution is as follows:
First, if you're an administrator, check that your following switches are on:
 

vlinyulumsft_0-1723431601918.png

 

Second, add normally:

vlinyulumsft_1-1723431601919.png

vlinyulumsft_4-1723431957989.png

You can also use PowerShell to add it, here's a screenshot of the official documentation for the content:

vlinyulumsft_5-1723431957991.png

Here is the relevant documentation:

Embed Power BI content in an embedded analytics application with service principal and an applicatio...
Automate Power BI Premium workspace and semantic model tasks with service principals - Power BI | Mi...


Of course, if you have any new ideas, you are welcome to contact us.
 

Best Regards,

Leroy Lu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

@Anonymous : Thank you for the reply. 
I had added service principal as admin to the workspace, and from what you mentioned above I have also enabled settings in the PowerBI Admin portal. 
However when I try to run this API call, I get this error -
"pbi.error":{"code":"PowerBINotAuthorizedException","parameters":{},"details":[],"exceptionCulprit":1}


What am I missing ?

 
Thanks in advance !
Anonymous
Not applicable

HI,@Shree007 
Thanks for the quick reply.
 

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.

In response to your question, based on the information I've gathered, you can try the following:

1.First, you can try adding the service principal to the security group and then perform a similar operation on the security group to see if that solves the problem.

Here are screenshots and links to the relevant answers:
 

vlinyulumsft_0-1723711516864.png
2.Second, you can try removing the permissions granted.

The access token is then decoded using a JWT token decoder to check for the presence of a key/value pair.
 

3.Finally, if the token still contains the value of the key/value pair, create a new app that doesn't have permissions and add it to an existing security group.
 

Here are screenshots and links to the relevant answers:

vlinyulumsft_1-1723711516866.png

 

python - Power BI Rest API Requests Not Authorizing as expected - Stack Overflow
Of course, hopefully you will back up your important data before trying my advice to see if that solves the problem.


I
f you have any new ideas, you are welcome to contact us.
 

Best Regards,

Leroy Lu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Community Champion
Community Champion

@Shree007 First question I would have is whether or not you can go into the Service and manually assign the workspace to the premium capacity.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler yes, am able to assign premium license capacity to a workspace from the PBI online service. Just doesn't work via the API call.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.