简体   繁体   English

Power BI:尝试更新参数 vi PowerShell API 调用

[英]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.我在使用 PowerShell 脚本通过 Power BI rest api 更新数据集参数时遇到了一些困难。

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 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.我已经定义了一个名为ReportVersion的字符串参数,我正在尝试更新它。 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.我知道它是在 2020 年被问到的,我会在 2 年后回答它,但对于任何被卡住的人。

The parameter values are not editable when the data type of parameter is set to ANY.当参数的数据类型设置为 ANY 时,参数值不可编辑。 Make sure that your parameter data type is NOT set to ANY, it must be set to Text or Decimal.确保您的参数数据类型未设置为 ANY,它必须设置为 Text 或 Decimal。

参数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM