Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
jvembenil
Frequent Visitor

power bi rest api get all reports with endorsements

I finally got my powershell script working to call the Power BI rest methods to extract all workspaces and reports in workspaces.
But What I am missing is the the endorsement labels for each report. Does anyone know how I can modify this script get that info?

Any help would be appreicated.

 

# need to set this to ensure proper connections
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

# import modules and login
Import-Module MicrosoftPowerBIMgmt
Import-Module MicrosoftPowerBIMgmt.Profile
Connect-PowerBIServiceAccount

# initialize variables
$uriGroups = 'https://api.powerbi.com/v1.0/myorg/groups'

Write-Host "******* Reading Workspaces *****"
try {
    $workSpacesJson = Invoke-PowerBIRestMethod -Url $uriGroups -Method Get
    $workspaceContents = $workSpacesJson | ConvertFrom-Json 
    $workspaceCount = $workspaceContents.value.count
    $workspaces = $workspaceContents.value 
    Write-Host "Total workspaces:" $workspaceCount

# loop thru the workspaces and get the reports
    foreach ($workspace in $workspaces) {
        $uriReports = $uriGroups + "/" + $workspace.id + "/reports?$expand=endorsementDetails"
        $reportsJson = Invoke-PowerBIRestMethod -Url $urireports -Method Get
        $reportsContents = $reportsJson | ConvertFrom-Json 
        $reportsCount = $reportsContents.value.count
        #$reports = $reportsContents.value 
        Write-Host "Total reports in workspace:" $reportsCount

        Write-Host "******* Exporting workspaces to json file *****"
        $ExportFile = "./export/Reports_"+$workspace.name+".json"
        $reportsJson | Out-File $ExportFile
    }
    if (-Not $?) {
    $errmsg = Resolve-PowerBIError -Last
    $errmsg.Message
    }
} catch {
    $errmsg = Resolve-PowerBIError -Last
    $errmsg.Message
}

Write-Host "******* Exporting workspaces to json file *****"
$ExportFile = "./export/WorkSpaces.json"
$workSpacesJson | Out-File $ExportFile

Disconnect-PowerBIServiceAccount
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

here's one of the ideas around that. Says "Needs Votes"  🙂

 

Microsoft Idea · Report Endorsement (powerbi.com)

 

View solution in original post

5 REPLIES 5
cbilsoe
Frequent Visitor

Picking up on an old topic, but since it is now possible to endorse both Dataset and Reports in the Power BI service can someone explain why this endorse information is not possible to retrieve via the Power BI Rest API???
 @v-shex-msft responded to another thread similar to this but it seems this has also been dropped Microsoft Idea (powerbi.com)

Boxmodern
Advocate IV
Advocate IV

It looks like the API documentation is still incorrect. EndorsementDetails are not returned by Get Report or Get Reports in Group.

lbendlin
Super User
Super User

here's one of the ideas around that. Says "Needs Votes"  🙂

 

Microsoft Idea · Report Endorsement (powerbi.com)

 

lbendlin
Super User
Super User

I think this is one of these rare cases where the documentation is ahead of the implementation.  I am sure the API team is working on updating that call's return structure.

Thanks for the input @lbendlin . Do you know if there is an idea out there for this or another location where I can post the request to the API team?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.