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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
RogerSteinberg
Post Patron
Post Patron

Update parameters through Powershell

Hello,

 

I need help in creating a simple PowerShell script that will update my PBI report parameter.

Body:
{
  "updateDetails": [
    {
      "name": "EndDate",
      "newValue": "2020-06-08"
    },
    {
      "name": "StartDate",
      "newValue": "2020-06-01"
    }
  ]
}

I'm not sure how to followup this code:

Invoke-PowerBIRestMethod -Url "/datasets/datasetID" -Method Post -Body .....

 This is provided by the Microsoft documentation but i'm having trouble putting it into practice

Invoke-PowerBIRestMethod
      -Url <String>
      -Method <PowerBIWebRequestMethod>
      [-Body <String>]
      [-OutFile <String>]
      [-ContentType <String>]
      [-Headers <Hashtable>]
      [-Organization <String>]
      [-Version <String>]
      [<CommonParameters>]

Thank you for your help!

1 ACCEPTED SOLUTION

I found it out:

# Update Parameters URL
$urlUpdateParams = '/datasets/{datasetId}/Default.UpdateParameters'


# Update Parameters Body
$body = '{
  "updateDetails": [
    {
      "name": "EndDate",
      "newValue": "2020-06-14"
    },
    {
      "name": "StartDate",
      "newValue": "2020-06-01"
    }
  ]
}'

$content = 'application/json'

Invoke-PowerBIRestMethod -Url $urlUpdateParams -Method Post -Body $body -ContentType $content # Updates Dataset Parameters

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

Your API call is incomplete.

 

https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/updateparameters (for regular workspaces)

https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/updateparametersingroup (for Premium)

 

Note that you are not updating report parameters. You are updating dataset parameters.

I found it out:

# Update Parameters URL
$urlUpdateParams = '/datasets/{datasetId}/Default.UpdateParameters'


# Update Parameters Body
$body = '{
  "updateDetails": [
    {
      "name": "EndDate",
      "newValue": "2020-06-14"
    },
    {
      "name": "StartDate",
      "newValue": "2020-06-01"
    }
  ]
}'

$content = 'application/json'

Invoke-PowerBIRestMethod -Url $urlUpdateParams -Method Post -Body $body -ContentType $content # Updates Dataset Parameters

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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