Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

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())

  • 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)

  • Deku's avatar
    Deku
    1 year ago

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

5 Replies

  • 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 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)

  • v-sgandrathi's avatar
    v-sgandrathi
    Icon for Community Support rankCommunity 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!