I'm trying to get the powerbi apps details using the Azure Cloudshell,
Here is the Powershell script i'm using,
$secret="********"
$tenantId="********"
$appId="********"
$password= ConvertTo-SecureString $secret -AsPlainText -Force
$credential= New-Object System.Management.Automation.PSCredential ($appId, $password)
#Connecting to PowerBI
Connect-PowerBIServiceAccount -ServicePrincipal -Tenant $tenantId -Credential $credential
$accessToken = Get-AzAccessToken
#Get-PowerBIAccessToken
$authHeader = @{
'Content-Type'='application/json'
'Authorization'= $accessToken.Authorization
}
$uri="https://api.powerbi.com/v1.0/myorg/apps/****"
$allapps = (Invoke-RestMethod -Uri $uri –Headers $authHeader –Method GET).Value
$allapps.Name
When i'm running this cmd in Azure Cloudshell window, i'm getting bellow error, what could be the problem ?
I have added the SPN to the PowerBI Tenant settings and have API permission as below