Forum Discussion
GetScanResult endpoint does not return "datasourceInstances" list
- 3 months ago
Hi 1ng4lipt ,
Thank you for providing the detailed request flow. I have reviewed your implementation, and your PostWorkspaceInfo call appears to be correct. so the parameters are set appropriately. The use of true versus True will not affect the response in this context.
Notably, your scan result returns datasourceUsages with a valid datasourceInstanceId, indicating that the scan is successfully identifying the relationship between the dataset and its datasource. If there were an issue with the request, this information would typically not be present.
The absence of the datasourceInstances section generally occurs when the scan API cannot fully resolve the underlying datasource metadata. As outlined in the Microsoft documentation for GetScanResult, the API may only return certain properties depending on the metadata available in the Power BI service. As a result, the response can vary based on datasource type, connection configuration, gateway setup, or how the dataset was created.
This behavior is common with specific cloud connections, custom connectors, parameterized connections, dataflows, and certain Fabric related sources where the relationship is detected, but complete datasource details are not provided in the scan response.
Since your request is properly configured and the scan completes successfully, this appears to be related to the API’s metadata return for that datasource, rather than an issue with your code.
If you require comprehensive datasource connection details, I recommend using the Get Datasources As Admin endpoint, which is generally more reliable when datasourceInstances is missing.
For further reference, please see the following Microsoft documentation:
GetScanResult API documentation
https://learn.microsoft.com/rest/api/power-bi/admin/workspace-info-get-scan-resultPostWorkspaceInfo API documentation
https://learn.microsoft.com/rest/api/power-bi/admin/workspace-info-post-workspace-infoGet Datasources As Admin documentation
https://learn.microsoft.com/rest/api/power-bi/admin/datasets-get-datasources-as-admin
Thank you.
In case you, like me, use dlt to get response from PBI endpoints you can select datasourceInstances as selector to get datasource data.
{
"name": "get_scan_datasource_instances",
"primary_key": "datasourceId",
"write_disposition": "append",
"max_table_nesting": 0,
"endpoint": {
"path": "v1.0/myorg/admin/workspaces/scanResult/{scan_id}",
"params": {"scan_id": scan_id},
"data_selector": "datasourceInstances",
"paginator": {"type": "single_page"},
},
},response
"value": [
{
"datasourceType": "AnalysisServices",
"connectionDetails": {
"server": "My-As-Server",
"database": "My-As-Database"
},
"datasourceId": "33cc5222-3fb9-44f7-b19d-ffbff18aaaf5",
"gatewayId": "0a2dafe6-0e93-4120-8d2c-fae123c111b1"
}
- v-tejrama2 months agoCommunity Support
Hi 1ng4lipt ,
Thank you for sharing the solution and updating the thread.
This is a significant insight for others working with dlt and the Power BI Scan APIs.
Although the datasourceInstances data is available in the Scan Result response, it must be explicitly requested using the datasourceInstances data selector. With this setting enabled, the response provides the expected datasource metadata, including datasourceType, connectionDetails, datasourceId, and gatewayId.Thank you.