Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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())
Solved! Go to Solution.
@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)
Also check you have write permissions, read will allow you do GET but would need write fro PATCH
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!
@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)
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
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
24 | |
20 | |
18 | |
15 | |
13 |
User | Count |
---|---|
37 | |
23 | |
21 | |
18 | |
12 |