maikvandergaag / msft-extensions

Repository for extensions mainly used for Azure DevOps Extensions
https://msftplayground.com
MIT License
126 stars 81 forks source link

Power BI Actions: UpdateParameters - error: BadRequest or InvalidRequest #440

Closed sanjo220 closed 1 year ago

sanjo220 commented 1 year ago

Describe the issue Hi Maik,

I hope you are well and good. I would like to ask some assistance regarding this issue I am encountering:

I have a build pipeline in Azure DevOps that uses Power BI Actions: UpdateParameters action, but it throws a ##[error]BadRequest error when run.

Looking into the logs, the specific error is when trying to execute the following API call: POST https://api.powerbi.com/v1.0/myorg/groups/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/datasets/yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy/Default.UpdateParameters with -1-byte payload

Error:

[debug]Invoke-API : BadRequest

[debug]At D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.39\ps_modules\PowerBI\PowerBI.psm1:238 char:9

[debug]+ Invoke-API -Url $url -Method "Post" -Body $body -ContentType ...

[debug]+ ~~~~~~~~~~~~~

[debug] + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException

[debug] + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-API

[debug]

[debug]Script stack trace:

[debug]at Invoke-API, D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.39\ps_modules\PowerBI\PowerBI.psm1: line 307

[debug]at Update-PowerBIDatasetParameter, D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.39\ps_modules\PowerBI\PowerBI.psm1: line 238

[debug]at Update-PowerBIDatasetParameters, D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.39\ps_modules\PowerBI\PowerBI.psm1: line 261

[debug]at , D:\a_tasks\PowerBIActions_d5b7fec6-2b25-4742-905b-0dad97687df5\5.4.39\run.ps1: line 208

[debug]at , : line 1

[debug]at , : line 22

[debug]at , : line 18

[debug]at , : line 1

[debug]Exception:

[debug]Microsoft.PowerShell.Commands.WriteErrorException: BadRequest

[error]BadRequest

[debug]Processed: ##vso[task.logissue type=error]BadRequest

[debug]Processed: ##vso[task.complete result=Failed]

Extension

To Reproduce Steps to reproduce the behavior:

  1. Add Power BI Action step in Azure Pipeline's build
  2. Set Action to be Update parameters
  3. Set Workspace name (Update all datasets... option unchecked)
  4. Set specific Dataset name
  5. Set Update parameter json: [{'name':'SQL_server','newValue':'mysqlserver\name'},{'name':'Database','newValue':'mydatabase'}]
  6. Save the pipeline, run the build.

Expected behavior I would expect that the action finishes successfully without errors and parameters 'SQL_server' and 'Database' are successfully updated on the report's dataset in the specified workspace.

Situation (please complete the following information):

Log info power-bi-actions-update-parameters-log.txt

Additional information There is a preceding Power BI Action step set for the pipeline: Publish action. It is working fine. Let me know if you need the log for it too.

Add any other context about the problem here.

sanjo220 commented 1 year ago

After digging through some closed issues here, I found my issue is the same as #423 as my SQL Server name has the format of "xxxxx\yyy" also. When I applied the 4 backslashes to the parameter value ('\\'), it worked. But it produced a different error afterwards: InvalidRequest.

I noticed that InvalidRequest does not happen when the report being published is totally new/not yet existing in the workspace. It pops up when the report (already existing) is redeployed into the workspace. I was able to resolve this by adding another action before UpdateParameters action: TakeOwnership.

Once the additional step is added before UpdateParameters, everything worked well, whether it's a new report in a workspace or an existing one being overwritten. It even fixed my issue in the UpdateGateway step, where the report dataset is not being set although the right dataset name and gateway name are put.

To sum up, the following is now my working pipeline: Step 1: Power BI Action: Publish Step 2: Power BI Action: TakeOwnership Step 3: Power BI Action: UpdateParameters Step 4: Power BI Action: UpdateGateway

I am closing this case now.