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

Admin - Datasets GetDatasourcesAsAdmin API outputs incorrect Datasource information

Hello,

Admin - Datasets GetDatasourcesAsAdmin API (https://learn.microsoft.com/en-us/rest/api/power-bi/admin/datasets-get-datasources-as-admin?tryIt=tr...) has been listing wrong Datasources Information when it is iterated with the DatasetIDs from the Admin - Datasets GetDatasetsAsAdmin API (https://learn.microsoft.com/en-us/rest/api/power-bi/admin/datasets-get-datasets-as-admin).

 

Below is the code snippet of how I'm iterating using PowerShell. I'm authenticating using Service Principal which has the required permissions.

//

 

$DatasetsAPI = "https://api.powerbi.com/v1.0/myorg/admin/datasets"

$Datasets = Invoke-RestMethod -Uri $DatasetsAPI -Headers $headers -Method GET -ContentType "application/json"

$DatasetID = $Datasets.value.id

 

# Forloop to retrieve Datasource info for each DataSetID

foreach ($Id in $DatasetID){

 $DatasourceAPI = "https://api.powerbi.com/v1.0/myorg/admin/datasets/$Id/datasources"

 

try {

$Datasource = Invoke-RestMethod -Uri $DatasourceAPI -Headers $headers -Method GET -ContentType "application/json"

}

 

Catch {

$Datasource.value | select-object datasourceType, datasourceId, gatewayId, connectionDetails, @{n="DataSetID";e={$Id}}| Export-csv $ErrorPath -NoTypeInformation -Append -force

$iserror = $true

}

 

#Writes the Final output to a csv file

finally {

$Datasource.value | select-object datasourceType, datasourceId, gatewayId, connectionDetails, @{n="DataSetID";e={$Id}} | Export-csv $Path -NoTypeInformation -Append -force

 }

 $Datasource = $null

}

 

//

 

As for the result, the following dataset ID shows the connection details as '@{path=Goals; kind=Goals}' and when we run the same API in MSFT website it shows the actual results. This has been inconsistent in terms of the Dataset IDs that it will output the Connection details with this process.

 

saeruva02_0-1701468431627.png

 

 

saeruva02_1-1701468431629.png

 

If anyone has come across this use case and has a solution would be helpful. Thanks in advance!

1 REPLY 1
Anonymous
Not applicable

Hello, Trying to resurface this post to see if anyone knows of any solution. Thanks!

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.