Error while using the Export API to export Paginated report located on PBI Service into a .xlsx file

%3CLINGO-SUB%20id%3D%22lingo-sub-2474599%22%20slang%3D%22en-US%22%3EError%20while%20using%20the%20Export%20API%20to%20export%20Paginated%20report%20located%20on%20PBI%20Service%20into%20a%20.xlsx%20file%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2474599%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3EHi%20folks%2C%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20run%20this%20script%20to%20export%20paginated%20report%20into%20an%20excel%20file%20using%20PowerShell%20but%20I%20am%20getting%20an%20error%2C%20Could%20anyone%20please%20help%20me%3F%3C%2FP%3E%3CP%3EThings%20which%20ran%20successfully%20using%20PowerShell%20%3A%20Logging%20into%20PBI%20Service%20%2C%20Retrieving%20Workspace%20and%20Report%20ID%3C%2FP%3E%3CP%3E%3CEM%3E%24reportId%20%3D%20%227abc73b4-0bad-4edb-8f52-xxxxxxxxxxxx%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%24groupId%20%3D%20%2204a7c8b4-9c13-4838-b812-%20xxxxxxxxxxxx%20%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%24endpoint%20%3D%20%22%3CA%20href%3D%22https%3A%2F%2Fapi.powerbi.com%2Fv1.0%2Fmyorg%2Freports%2F%24reportId%2FExportTo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fapi.powerbi.com%2Fv1.0%2Fmyorg%2Freports%2F%24reportId%2FExportTo%3C%2FA%3E%22%20%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%24endpoint%20%3D%20%22%3CA%20href%3D%22https%3A%2F%2Fapi.powerbi.com%2Fv1.0%2Fmyorg%2Fgroups%2F%24groupId%2Freports%2F%24reportId%2FExportTo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fapi.powerbi.com%2Fv1.0%2Fmyorg%2Fgroups%2F%24groupId%2Freports%2F%24reportId%2FExportTo%3C%2FA%3E%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%24body%20%3D%20%40%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%7B%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22format%22%3A%20%E2%80%9CXLSX%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%7D%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%22%40%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%24headers%20%3D%20Get-PowerBIAccessToken%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%24headers.Add(%22Content-type%22%2C%20%22application%2Fjson%22)%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%24response%20%3D%20Invoke-RestMethod%20-Headers%20%24headers%20-Uri%20%24endpoint%26nbsp%3B%20-Body%20%24body%20-Method%20'Post'%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%24response%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3EError%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Ajeenkz369_0-1624443724481.png%22%20style%3D%22width%3A%201335px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F290641i6859475D0ECA935B%2Fimage-dimensions%2F1335x118%3Fv%3Dv2%22%20width%3D%221335%22%20height%3D%22118%22%20role%3D%22button%22%20title%3D%22Ajeenkz369_0-1624443724481.png%22%20alt%3D%22Ajeenkz369_0-1624443724481.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2474599%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPower%20BI%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

Hi folks,

I am trying to run this script to export paginated report into an excel file using PowerShell but I am getting an error, Could anyone please help me?

Things which ran successfully using PowerShell : Logging into PBI Service , Retrieving Workspace and Report ID

$reportId = "7abc73b4-0bad-4edb-8f52-xxxxxxxxxxxx"

$groupId = "04a7c8b4-9c13-4838-b812- xxxxxxxxxxxx "

$endpoint = "https://api.powerbi.com/v1.0/myorg/reports/$reportId/ExportTo"

$endpoint = "https://api.powerbi.com/v1.0/myorg/groups/$groupId/reports/$reportId/ExportTo"

$body = @"

{

    "format": “XLSX"

}

"@

$headers = Get-PowerBIAccessToken

$headers.Add("Content-type", "application/json")

$response = Invoke-RestMethod -Headers $headers -Uri $endpoint  -Body $body -Method 'Post'

$response

Error:

Ajeenkz369_0-1624443724481.png

 

0 Replies