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://learn.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
I know it was asked in 2020 and I am answering it 2 years later but for anyone who is stuck.
The parameter values are not editable when the data type of parameter is set to ANY. Make sure that your parameter data type is NOT set to ANY, it must be set to Text or Decimal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With