Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
I am using the following code with the required permissions in the AD using service principal as mentioned in the document:
%script{src: "https://cdnjs.cloudflare.com/ajax/libs/powerbi-client/2.19.1/powerbi.min.js"}
%body
%h1 Sales By SKU Report
#reportContainer
:javascript
var models = window['powerbi-client'].models;
var embedConfig = {
type: "report",
id: "#{@report_id}",
embedUrl: "#{@embed_url}",
accessToken: "#{@embed_token}",
tokenType: models.TokenType.Embed,
permissions: models.Permissions.All,
viewMode: models.ViewMode.Edit,
settings: {
panes: {
filters: { visible: false },
pageNavigation: { visible: true }
}
},
filters: [
{
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "woah2_production organisations",
column: "id"
},
operator: "In",
values: []
}
]
};
var container = document.getElementById("reportContainer");
var report = powerbi.embed(container, embedConfig);
let saveAsParameters = {
name: "newReport"
};
report.saveAs(saveAsParameters);
I am getting the following error:
Am I mising any permissions here? Please help!
Hi @swapnil196 ,
We noticed we haven't received a response from you yet, so we wanted to follow up and ensure the solution we provided addressed your issue. If you require any further assistance or have additional questions, please let us know.
Your feedback is valuable to us, and we look forward to hearing from you soon.
Thanks..
Hi @swapnil196 ,
Has your issue been resolved, or do you require any further information? Your feedback is valuable to us. If the solution was effective, please mark it as 'Accepted Solution' to assist other community members experiencing the same issue.
Hi @swapnil196 ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You.
Hi @swapnil196 ,
Thank you for reaching out to us on the Microsoft Fabric Community Forum. This error happens because of limited permissions, licensing issues, or workspace ownership problems.
1. Even if the Service Principal is properly set up, it needs the correct role in the Power BI workspace to save reports.
If it's set as Viewer or Member, change it to Contributor or Admin.
Reference: Workspaces in Power BI - Power BI | Microsoft Learn
2. For the Service Principal to use the saveAs() function, make sure API access is enabled in the Power BI Admin settings.
Apply this setting to the Security Group that includes the Service Principal.
3. The saveAs() function only works for reports that are part of the workspace.
Make sure the report isn’t linked or shared from a different workspace. If needed, recreate the report within the workspace itself.
4. If you're using Power BI Pro, ensure the Service Principal has a Pro license.
If you're using Power BI Embedded, make sure the workspace is in Premium Capacity.
Verify that the workspace is assigned to Premium Capacity or confirm the Service Principal has a Power BI Pro license.
Reference: Power BI Premium Per User - Power BI | Microsoft Learn
5. Even if the Service Principal can access the report, it still needs Build permissions on the dataset to save changes.
If the permissions were updated recently, make sure to refresh them using the Power BI REST API.
As an alternative solution.
if the saveAs() function isn't working, consider using the Clone Report API. This API enables you to create a duplicate copy of the report.
I hope this heps. If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.