Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
In PowerShell I am issuing the following to the Power BI API to get dashboards while expanding tiles:
$dashboardsApiUrl = "https://api.powerbi.com/v1.0/myorg/admin/dashboards?$expand=tiles"
#$dashboardsApiUrl = "https://api.powerbi.com/v1.0/myorg/admin/dashboards/{dashboardGuid}/tiles"
$apiDashboardsResult = Invoke-PowerBIRestMethod -Url $dashboardsApiUrl -Method Get
echo $apiDashboardsResult
The call is successful, no errors, but the Json result does not contain a Tiles array. If I use the /tiles REST endpoint, as commented out on 2nd line, I can get tiles. Would be much more efficient in terms of time to execute if expand worked and I could avoid the roundtrip for each dashboard in the org. Am I doing something wrong or is the API busted? I believe I am following the Documentation to the letter. I don't see a way to get the Tiles collection using
Get-PowerBIDashboard -Scope Organization
Here is a full test case PowerShell script to show the issue:
Login-PowerBI
$ApiUrl = 'https://api.powerbi.com/v1.0/myorg/admin/dashboards?$expand=tiles'
echo $ApiUrl
$apiResult = Invoke-PowerBIRestMethod -Url $datasourceApiUrl -Method Get
#datasetId is a property on the tiles object, it should be found if tiles were included
if($apiResult -like '*datasetId*')
{ echo "Found datasetId" } else {echo "Can't find word datasetId in result"}
#control group, should find isReadOnly as it is part of the Dashboard Object and proving casing doesn't matter in search
if($apiResult -like '*isreadonly*')
{ echo "Found IsReadOnly" } else {echo "Can't find word IsReadOnly in result"}
$apiObjectResult = $apiResult | ConvertFrom-Json
$dashboards = $apiObjectResult.value
ForEach ($d in $dashboards)
{
ForEach($tile in $d.tiles)
{
echo "found a tile"
echo $tile
}
}
echo "done"
The output window shows the following:
https://api.powerbi.com/v1.0/myorg/admin/dashboards?$expand=tiles
Can't find word datasetId in result
Found IsReadOnly
done
Solved! Go to Solution.
I discovered the "Try It" button on the API documentation page. After playing with this it gave me more meaningful responses then then the Power BI Invoke-PowerBiResetMethod cmdlet does. I discovered I needed to add the $top query parameter in order for the $expand parameter to take effect. When using the cmdlet it apears the behavior is just to throw out the $expand parameter if $top is missing and sweep it all under the rug pretending nothing happened. Final URL endpoint to get it working....
https://api.powerbi.com/v1.0/myorg/admin/dashboards?$expand=tiles&$top=5000
I discovered the "Try It" button on the API documentation page. After playing with this it gave me more meaningful responses then then the Power BI Invoke-PowerBiResetMethod cmdlet does. I discovered I needed to add the $top query parameter in order for the $expand parameter to take effect. When using the cmdlet it apears the behavior is just to throw out the $expand parameter if $top is missing and sweep it all under the rug pretending nothing happened. Final URL endpoint to get it working....
https://api.powerbi.com/v1.0/myorg/admin/dashboards?$expand=tiles&$top=5000
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
1 | |
1 | |
1 | |
1 |
User | Count |
---|---|
25 | |
3 | |
2 | |
2 | |
2 |