Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Dom87326
Helper II
Helper II

Problems using Invoke-PowerBIRestMethod to update parameters

Hello community,

 

I’m working with multiple workspaces, reports and using powershell script that takes simple CSV file to determine what .pbix file goes into which workspace and what parameters to update (if any).

The script is really simple. It verifies if report name (full path has been received as a command line parameter) exists in the publisher.csv file. If exists then extract all values from a corresponding row (workspace name, dataset refresh request, parameter1 and parameter2 name, parameter1 value and parameter2 value) from the publisher.csv file (based on this blog).

 

To test the script, I'm using hardcoded $body and $url variables with Invoke-PowerBIRestMethod REST POST call:

 

 

#Group ID and Dataset ID 
$urlbase = "groups/4bc15b4f-5dc8-49e3-aaba-XXXXXXXXXXXX/datasets/AAAAAAAA-YYYY-4cb8-898a-222261a5e0d0/"

$body = '{
	updateDetails: [
    {
      "name": "%Date",
      "newValue": "11111111"
    },
    {
      "name": "%Customer",
      "newValue": "Amazon"
    }
   ]
}'

#url and body for UpdateParameters in API call
$url = $urlbase + "UpdateParameters"

Invoke-PowerBIRestMethod -Url $url -Method Post -Body $body -ContentType application/json

 

 


However I receive following error: 

 

 

Invoke-PowerBIRestMethod : One or more errors occurred.
At C:\Users\UserName\FolderPath\Publish one report.ps1:52 char:5
+     Invoke-PowerBIRestMethod -Url $url -Method Post -Body $body -Cont ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIRestMethod], Aggregat 
   eException
    + FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
 

 

 

 

Has anyone faced similar issues with this workflow? 

 

Many thanks in advance!

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi  @Dom87326 ,

Whether your problem has been resolved? If yes, could you please mark the helpful post as Answered? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yiruan-msft
Community Support
Community Support

Hi @Dom87326,

Are "%Date" and "%Customer" the actual paramater name? And the names were originally preceded by a prefix "%"? Is the date type of "%Date" Text type or Date type? Could you please refer the following thread to change the codes as below and check if it can work....

Update parameters through Powershell

#Group ID and Dataset ID 
$urlbase = "groups/4bc15b4f-5dc8-49e3-aaba-XXXXXXXXXXXX/datasets/AAAAAAAA-YYYY-4cb8-898a-222261a5e0d0/"

$body = '{
	updateDetails: [
    {
      "name": "%Date",
      "newValue": "11111111"
    },
    {
      "name": "%Customer",
      "newValue": "Amazon"
    }
   ]
}'

#url and body for UpdateParameters in API call
$url = $urlbase + "Default.UpdateParameters"

$content = 'application/json'

Invoke-PowerBIRestMethod -Url $url -Method Post -Body $body -ContentType $content

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Top Solution Authors