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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Update report content using rest api returns Unauthorized

I'm trying to create a functioning CI/CD setup. Using UpdateReportContent I want to update the Production report with the Test report.

I'm calling the REST API using the Service Principal and it all works fine for other stuff, i.e. getting reports, uploading pbix files.

The SP has admin rights to both Test and Production workspace. The Service Principal also have the correct permissions (Report.ReadWrite.All) registered in the App Registration in Azure AD.

I've tried this using Postman and by calling the REST API with Powershell, both with the same 401 Unauthorized result. 

 

However when I use the "playground / try it" here signing in with my own personal account (which also have admin rights) i can update the report. The request body I used is the same as the one from postman, therefore verifying that my json body is correct.

 

Anyone who have been able to update the report using the REST api with Service Principal ?

 

Response: 

{"error":{

"code":"PowerBINotAuthorizedException",

"pbi.error":{

"code":"PowerBINotAuthorizedException",

"parameters":{},

"details":[],

"exceptionCulprit":1

}}}

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Update: I found that Clone (https://docs.microsoft.com/en-us/rest/api/power-bi/reports/clonereportingroup) report works over different workspaces so I decided to go with that solution. 

One problem with it is that it does not replace a report if there's a name conflict, and I can't choose to specify a report id to replace. So what I did was to get reports (https://docs.microsoft.com/en-us/rest/api/power-bi/reports/getreportsingroup) and extract the one with matching name and do a delete (https://docs.microsoft.com/en-us/rest/api/power-bi/reports/deletereportingroup) on that report. 

Then I clone the report I want moved by specifing the dataset I want to use in the other workspace.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

It works when the reports are in the same workspace, just tried it by calling the rest api with powershell. 

 

Is this a limitation with Service Principal ? That you can't Update report content with reports from different workspaces

Anonymous
Not applicable

Update: I found that Clone (https://docs.microsoft.com/en-us/rest/api/power-bi/reports/clonereportingroup) report works over different workspaces so I decided to go with that solution. 

One problem with it is that it does not replace a report if there's a name conflict, and I can't choose to specify a report id to replace. So what I did was to get reports (https://docs.microsoft.com/en-us/rest/api/power-bi/reports/getreportsingroup) and extract the one with matching name and do a delete (https://docs.microsoft.com/en-us/rest/api/power-bi/reports/deletereportingroup) on that report. 

Then I clone the report I want moved by specifing the dataset I want to use in the other workspace.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors