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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Cortana
Helper III
Helper III

How to change parameter using REST API?

I wanted to change the parameter of a dataset using Python. I created an app with permission Dataset.ReadWrite.ALL from Azure AD.
I was able to get the Access token successfully but could not change the parameter. My code is this-

access_token = 'MY_ACCESS_TOKEN'
workspace_id = "MY_Workspace_ID"
dataset_id = "MY_Dataset_ID"
header = {'Content-Type':'application/json',
          'Authorization':f'Bearer {access_token}'}

# Replace these with your details
parameter_name = 'NAME'
new_value = 'VALUE'

# Define the API endpoint
url = f'https://api.powerbi.com/v1.0/myorg/groups/{workspace_id}/datasets/{dataset_id}/Default.UpdateParameters'

# Create the headers
headers = {
    'Content-Type': 'application/json',
    'Authorization': f'Bearer {access_token}'
}

# Define the body with the parameter update details
body = {
    "updateDetails": [
        {
            "name": parameter_name,
            "newValue": new_value
        }
    ]
}

# Make the API request
response = requests.post(url, headers=headers, data=json.dumps(body))
print(response.status_code)
print(response.json())

It gives output-

403

{'error': {'code': 'InvalidRequest', 'message': 'This operation is only supported for the dataset owner'}}

 

NB: I am the owner of the dataset. 

 

Am I missing something here? Your help is needed.

1 ACCEPTED SOLUTION
FabricGuy
Microsoft Employee
Microsoft Employee

Hi Cortana

 

The error message says that your Service Principal (SPN) is not the Owner of the Semantic Model. I guess you created the report in Power BI Desktop and published it afterwards on behalf of your name. Now, that you wish to update the Parameter, you first need to take ownership by calling this REST API call with the SPN in your Python code: https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/take-over-in-group Afterwards, once the SPN is owner, your call to update the parameter will work.

 

Hope it helps.

View solution in original post

2 REPLIES 2
FabricGuy
Microsoft Employee
Microsoft Employee

Hi Cortana

 

The error message says that your Service Principal (SPN) is not the Owner of the Semantic Model. I guess you created the report in Power BI Desktop and published it afterwards on behalf of your name. Now, that you wish to update the Parameter, you first need to take ownership by calling this REST API call with the SPN in your Python code: https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/take-over-in-group Afterwards, once the SPN is owner, your call to update the parameter will work.

 

Hope it helps.

Thank you so much @FabricGuy  It worked.

 

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.