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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

API error using service principal

Hi. I'm trying to automate PowerBI report deployment and actions related with that. Due to organization policy I have to use service principal. The service principal access in PowerBI is enabled and security group with created SP as a member is added. I set created SP as an admin of workspace. The following permissions for AAD app have been granted: User.Read, Content.Create, Dashboard.ReadWrite.All, Dataset.ReadWrite.All, Gateway.ReadWrite.All, Report.ReadWrite.All, Report.ReadWrite.All.  When I'm using PowerBI cmdlets for Powershell everything looks fine, eg. the following code is working as expect. 

$secret = $ClientKey | ConvertTo-SecureString -AsPlainText -Force 
$credential = New-Object -TypeName System.Management.Automation.PSCredential($ApplicationId, $secret) 
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId $TenantId 
[...]
Remove-PowerBIReport -Id $ReportToDelete.Id -WorkspaceId $Workspace.Id

 

But when I'm trying to do the same using Invoke-PowerBIRestMethod or Rest API sth is wrong:

$secret = $ClientKey | ConvertTo-SecureString -AsPlainText -Force 
$credential = New-Object -TypeName System.Management.Automation.PSCredential($ApplicationId, $secret) 
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId $TenantId
$Headers = Get-PowerBIAccessToken 
[...] 
$Uri = 'https://api.powerbi.com/v1.0/myorg/reports/'+ $ReportToDelete.Id 
Invoke-PowerBIRestMethod -Url $Uri -Method Delete 
or 
Invoke-RestMethod -Uri $Uri -Headers $Headers -Method Delete

 

Error for Invoke-PowerBIRestMethod: "One or more errors occurred. (Response status code does not indicate success: 403 (Forbidden).)"

Error for Invoke-RestMethod: "API is not accessible for application"

 

Do you have any ideas what's going on and what can be a problem? I need to use Rest API because PowerBI cmdlets for Powershell are not enough.

2 REPLIES 2
Anonymous
Not applicable

I have exactly same issue

Anonymous
Not applicable

It looks like the permissions issue. All the permissions granted in AAD I specified above. All the tenant permission in Power Bi Admin Portal are applied for the entire organization. What can be missing?

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.