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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

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

@Anonymous 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 @Anonymous 

 

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

@Anonymous 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 @Anonymous 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.

Anonymous
Not applicable

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.