Forum Discussion
invoke-ASCmd : The remote server returned an error: (400) Bad Request.
After 2023-08-30 a Powershell script to refresh PBI dataset in PBI Service PPU start returning this error: The remote server returned an error: (400) Bad Request.
The PowerBI PPU Dataset is refreshed and we can see in the service the refresh status as Completed.
The code that was working for months:
# ClientID
$User = '75a17c31.....4b1611a3cec2' #Application ID
# Secret Key
$PlainPassword = 'yB....' #Value Secret
$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $SecurePassword
$TmslScript = @"
{
"sequence": {
"maxParallelism": 8,
"operations": [
{
"refresh": {
"type": "dataOnly",
"objects": [{"database":"U - Dataset",...,"table":"Calendário - Mala Histórico"}]
}
},
{
"refresh": {
"type": "calculate",
"objects": [
{
"database": "UNILab - Dataset"
}
]
}
}
]
}
}
"@
$global:xmlaEndpoint= "powerbi://api.powerbi.com/v1.0/9c4d0cc9...4409d8/DI%20-%20Datasets%20PPU"
$DatasetName = "UNILab - Dataset"
Invoke-ASCmd -ServicePrincipal -Credential $cred -Query $TmslScript -Server: $xmlaEndpoint -Database $DatasetName