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
Title:
Getting "Insufficient permissions" error while saving semantic model changes using TOM and service principal
Body:
Hi everyone,
I'm working on a solution to add a DAX measure programmatically to a Power BI dataset using the Tabular Object Model (TOM) via a service principal. The datasets are hosted in a Premium capacity workspace.
Below are the steps I follow, including relevant code:
1. Connection string:
Data Source=powerbi://api.powerbi.com/v1.0/myorg/{workspaceName};
User ID=app:{_clientId}@{_tenantId};
Password={_clientSecret};2. Connecting to the server:
server.Connect(connectionString);
3. Connecting to the database:
Tabular.Database? database = server.Databases
.Cast<Tabular.Database>()
.FirstOrDefault(db => db.Name.Equals(datasetName, StringComparison.OrdinalIgnoreCase));
if (database == null)
return;4. Accessing the model:
Tabular.Model model = database.Model;
5. Finding the table:
var table = model.Tables.Find(tableName);
6. Checking if the measure already exists:
var existingMeasure = table.Measures.Find(measureName);
7. Creating a new measure:
var newMeasure = new Tabular.Measure
{
Name = measureName,
Expression = measureExpression,
FormatString = "#,0"
};8. Adding the measure to the table:
table.Measures.Add(newMeasure);
9. Saving the model changes:
model.SaveChanges();
Problem:
While this works for some datasets, it fails for others with the following error:
"Failed to save modifications to the server. Error returned: 'The request to alter the semantic model was rejected because of insufficient permissions. In addition to Write permissions on the model, make sure you also have at least Use permissions on all data connections that the semantic model uses. Verify the connection configuration in the semantic model settings and contact the connection owner(s) to grant you the required permissions.'"
What I've verified:
The service principal has ReadWrite permissions on both the workspace and dataset.
The dataset is hosted in a Premium capacity.
The same process and permissions work for other datasets.
Questions:
What could be causing this inconsistency between datasets?
How do I verify or assign "Use permissions" for all data sources to the service principal?
Is there a way to programmatically check permissions or data source access before calling SaveChanges()?
Any guidance or insights would be appreciated. Thanks!
Solved! Go to Solution.
Hi @Himanshu_G ,
Check with your Power BI / Fabric Administrator whether new security or governance policies were applied recently.
If you’re using service principals or automation to save semantic models, new consent and security checks may now block saving unless explicitly approved in the tenant settings.
Check in the Power BI Admin Portal if you have access:
Go to Admin Portal > Tenant settings > Export and sharing settings
Look under: “Publish datasets”, “Allow semantic model editing”, etc.
Create or edit a new test model in the same workspace. If that works, the issue is likely dataset-specific permission or ownership, not workspace-wide.
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.
Regards,
Chaithra.
Hi @Himanshu_G ,
As i haven't heard back from you, please let me know if the provided answer was helpful, please mark it as "Accept as solution" and click "Yes" if you found it helpful, it will be helpful for other members of the community who have similar problems as yours to solve it faster.
Regards,
Chaithra.
Hi @Himanshu_G ,
If the provided answer was helpful, please mark it as "Accept as solution" and click "Yes" if you found it helpful, it will be helpful for other members of the community who have similar problems as yours to solve it faster.
Regards,
Chaithra.
Hi @Himanshu_G ,
Check with your Power BI / Fabric Administrator whether new security or governance policies were applied recently.
If you’re using service principals or automation to save semantic models, new consent and security checks may now block saving unless explicitly approved in the tenant settings.
Check in the Power BI Admin Portal if you have access:
Go to Admin Portal > Tenant settings > Export and sharing settings
Look under: “Publish datasets”, “Allow semantic model editing”, etc.
Create or edit a new test model in the same workspace. If that works, the issue is likely dataset-specific permission or ownership, not workspace-wide.
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.
Regards,
Chaithra.
This was working fine until last month.
Has there been any permission or policy update from Power BI recently?
Hii @Himanshu_G ,
Check Permissions via REST API
GET https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/datasources
Ensure the service principal has access to all listed data sources.
Even though the service principal has admin access on the SQL database, check if it has Use permissions on the connection within Power BI.
Go to Manage Gateway & Data Sources in Power BI and verify access.
Row-level security (RLS) might also affect the ability of users with read or build permission on a semantic model to read data from the semantic model.
Thanks and Regards,
Chaithra.
Hi @v-echaithra ,
Thanks for your input.
Using the mentioned API, we are able to retrieve the datasourceId, but it doesn't provide visibility into the permissions applied to the dataset or the specific data source permissions for the service principal.
In our current scenario, RLS is not applied on the dataset we're working with.
Let me know if there's an alternate way to programmatically validate the service principal’s permissions on the dataset/data source.
Best regards,
Himanshu
Hi @Himanshu_G ,
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.
Regards,
Chaithra.
I have a few more details and questions:
We've created a report using a SQL Database as the data source. The service principal has admin access on that SQL Database.
The report is published to a workspace where the service principal also has admin access.
Despite this, the service principal still encounters the "insufficient permissions" error when trying to save a new measure or table using TOM.
Given the above setup, what else could be causing this permission issue? Is there a way to confirm whether the service principal has the necessary "Use permissions" on the data source connection used by the dataset?
Hi @Himanshu_G The issue might be due to the service principal lacking "Use permissions" on one or more data sources in the affected datasets. Verify data source permissions in Power BI Service under Manage Permissions or use the REST API to list and check dataset data sources. Ensure the service principal has "Build" and "Write" permissions for the dataset. Use the REST API to programmatically validate data source access before calling SaveChanges().
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 56 | |
| 55 | |
| 31 | |
| 18 | |
| 14 |