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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
mamatha5195
Microsoft Employee
Microsoft Employee

Query regarding Fabric connection API's

I am using below request.patch() API to map the connection ID to Fabric semantic model automatically in python script. But recieved error that the resource is not available in the URL. But for requests.get() I am able to get the existing datasource details. Please let me know which API works for patching the connection details using connectionid.

update_payload = {
"datasources": [
{
"datasourceId": datasource_id 
}
]
}

url = f"https://api.powerbi.com/v1.0/myorg/groups/{target_workspace_id}/datasets/{target_model_id}/datasourc..."
response = requests.patch(url, json=update_payload, headers=headers)

if response.status_code == 200:
print("Dataset successfully mapped to the specific connection.")
else:
print(f"Error: {response.status_code}")
print(response.json())

2 ACCEPTED SOLUTIONS
Akash_Varuna
Super User
Super User

@mamatha5195 In the Power BI REST API documentation, the correct endpoint for updating a dataset's data sources is:

PATCH https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId}/Default.UpdateDatasources

The key difference is that you should use /Default.UpdateDatasources instead of /datasources at the end of the URL, which aligns with the correct API method for updating data sources.
Please reffer the official documentation link for further clarification : ​

🔗 Datasets - Update Datasources In Group - REST API (Power BI)

View solution in original post

Also check you have write permissions, read will allow you do GET but would need write fro PATCH


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

5 REPLIES 5
v-sgandrathi
Community Support
Community Support

Hi @mamatha5195 

 

Has your issue been resolved?If the response provided by the community member addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.

If yes, kindly accept the useful reply as a solution and give us Kudos. It would be appreciated.

 

Thank you for your understanding!

Akash_Varuna
Super User
Super User

@mamatha5195 In the Power BI REST API documentation, the correct endpoint for updating a dataset's data sources is:

PATCH https://api.powerbi.com/v1.0/myorg/groups/{groupId}/datasets/{datasetId}/Default.UpdateDatasources

The key difference is that you should use /Default.UpdateDatasources instead of /datasources at the end of the URL, which aligns with the correct API method for updating data sources.
Please reffer the official documentation link for further clarification : ​

🔗 Datasets - Update Datasources In Group - REST API (Power BI)

Akash_Varuna
Super User
Super User

Hi @mamatha5195 The issue might be that the endpoint URL is incorrect or the resource is unavailable for patching. It could also be due to missing permissions or an invalid datasourceId. Try ensuring the URL structure is correct, and check if the datasource ID is valid for patching. If the issue persists, try printing the full error response (response.text) for more details.

Hi @Akash_Varuna , The same URL is working fine for getting the existing connection details. Data source ID is the connection ID which I have copied from the required connection. But when I try to run Patch request it is giving below error 
Error: 404 {'error': {'code': '', 'message': "No HTTP resource was found that matches the request URI 'https://df-msit-scus-redirect.analysis.windows.net/v1.0/myorg/groups/XXXXXXXXXXXX/datasets/xxxxxxxxx...'."}}

Also check you have write permissions, read will allow you do GET but would need write fro PATCH


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.