I am having some difficulties updating a dataset parameter via the Power BI rest api using a PowerShell script.
I have based my script on these resources:
https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/updateparameters https://community.powerbi.com/t5/Developer/Update-parameters-through-Powershell/td-p/1167203
I am pretty sure I got the syntax right, but the script sometimes returns an error, and I can't see any change in the dataset after running it.
I have defined a string parameter named ReportVersion which I am trying to update. The parameter has "enable load" checked off and is visible in the report.
This is how I attempt to do it:
Import-Module MicrosoftPowerBIMgmt
Connect-PowerBIServiceAccount
$datasetId = "my dataset id"
$urlUpdateParams = "https://api.powerbi.com/v1.0/myorg/datasets/$($datasetId)/Default.UpdateParameters"
$body = '{
"updateDetails": [
{
"name": "ReportVersion",
"newValue": "2.0"
}
]
}'
$content = 'application/json'
Invoke-PowerBIRestMethod -Url $urlUpdateParams -Method POST -Body $body -ContentType $content
Disconnect-PowerBIServiceAccount
The error I get looks like this:
At C:\...\Power BI report upload tool 10.ps1:83 char:17
+ ... Invoke-PowerBIRestMethod -Url $urlUpdateParams -Method PO ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
Can you help me pinpoint what is going wrong?
Thanks in advance,
Mike
