Hi,
I have a PowerShell script for Rebind my report in a workspace.
$clientId = "myClientId"
$clientSec = "myClientSecret" | ConvertTo-SecureString -AsPlainText -Force
$tenantId = "myTenantId"
$credential = New-Object System.Management.Automation.PSCredential($clientId, $clientSec)
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $credential -TenantId $tenantId
$Workspace = Get-PowerBIWorkspace -Name WorkspaceName
$WorkspaceId = $Workspace.Id
write-host $WorkspaceId
$report = Get-PowerBIReport -WorkspaceId $WorkspaceId -Name ReportName
$reportId = $report.ID
write-host $reportId
$dataset = Get-PowerBIDataset -WorkspaceId $WorkspaceId
$datasetId = $dataset.ID
write-host $datasetId
# Get token
$token = Get-PowerBIAccessToken -AsString
write-host $token
# Building Rest API header with authorization token
$authHeader = @{
"Authorization"= $token
"Content-Type" = "application/json"
}
# POST body
$postParams = @{
"datasetId" = "$datasetId"
}
$jsonPostBody = $postParams | ConvertTo-JSON
# Rebing reports
When I run that I get this error:
"Invoke-PowerBIRestMethod : Une ou plusieurs erreurs se sont produites.
Au caractère path\Desktop\TestRebind.ps1:38 : 1
+ Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/gro ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
+ FullyQualifiedErrorId : Une ou plusieurs erreurs se sont produites.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod"
My token looks like : "Bearer *********"
My API permissions are Read and Write ALL except for Tenant because I am not admin
Someone can help me please ?