Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Power BI: Attempting to update parameter vi PowerShell API call

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

like image 525
Mike Avatar asked Sep 10 '25 09:09

Mike


1 Answers

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.

Parameters

like image 181
Ankit Suhail Avatar answered Sep 13 '25 07:09

Ankit Suhail