Forum Discussion
send report in pdf
- 6 years agoSubscribing to PBIX reports as PDF is currently not supported. It’s in our planned backlog. We will get to it in coming months but no specific timeline to share yet.
Hi Greg_Deckler ,
Thanks for your reply. I am also getting the same error.
It would be really helpful if any body help me out on the below code.
$params = @{"format"="PDF"}
Invoke-PowerBIRestMethod -Method POST -Url reports/a9b01471-0982-4e14-bbf7-ddb60a89ab43/ExportTo -Body $params
Regards,
Prakash
Well, this is what I am seeing but I know I have full Admin access to this workspace so I don't know why I am getting 403 Forbidden. Anonymous v-easonf-msft rpatkar Pikachu-Power Jayendran Mariusz edhans parry2k VasTg az38 HotChilli
Anyone know why this doesn't work? I would be happy with a simple PNG export at this point.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\WINDOWS\system32> cd \temp
PS C:\temp> Connect-PowerBIServiceAccount
Environment : Public
TenantId :
UserName : [email protected]
PS C:\temp> Invoke-PowerBIRestMethod -Method POST -Url reports/4557598e-158d-407e-90e5-35a08b7c7584/ExportTo
WARNING: The Body parameter was null, the request may be invalid when Method parameter is Post.
Invoke-PowerBIRestMethod : One or more errors occurred.
At line:1 char:1
+ Invoke-PowerBIRestMethod -Method POST -Url reports/4557598e-158d-407e ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIR
estMethod], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
PS C:\temp> Resolve-PowerBIError
HistoryId: 3
Message : Response status code does not indicate success: 403 (Forbidden).
StackTrace : at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod.<InvokeRestMethod>d__31.MoveNext()
Exception : System.Net.Http.HttpRequestException
InvocationInfo : {Invoke-PowerBIRestMethod}
Line : Invoke-PowerBIRestMethod -Method POST -Url reports/4557598e-158d-407e-90e5-35a08b7c7584/ExportTo
Position : At line:1 char:1
+ Invoke-PowerBIRestMethod -Method POST -Url reports/4557598e-158d-407e ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 3
I have also tried this by creating a Service Principal, creating the application id, secret client key, adding the service principal to the workspace as Admin, here is the session from that, instead of 403 Forbidden I get back 401 Unauthorized. Note that I have also enabled Service Principal access to Power BI in the Tenant Settings Developer:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS C:\WINDOWS\system32> cd \temp
PS C:\temp> Connect-PowerBIServiceAccount -ServicePrincipal -Credential (Get-Credential)
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
Environment : Public
TenantId :
ClientId :
Password : ********
PS C:\temp> Invoke-PowerBIRestMethod -Method POST -Url reports/4557598e-158d-407e-90e5-35a08b7c7584/ExportTo
WARNING: The Body parameter was null, the request may be invalid when Method parameter is Post.
Invoke-PowerBIRestMethod : One or more errors occurred.
At line:1 char:1
+ Invoke-PowerBIRestMethod -Method POST -Url reports/4557598e-158d-407e ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (Microsoft.Power...werBIRestMethod:InvokePowerBIRestMethod) [Invoke-PowerBIR
estMethod], AggregateException
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod
PS C:\temp> Resolve-PowerBIError
HistoryId: 3
Message : Response status code does not indicate success: 401 (Unauthorized).
StackTrace : at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod.<InvokeRestMethod>d__31.MoveNext()
Exception : System.Net.Http.HttpRequestException
InvocationInfo : {Invoke-PowerBIRestMethod}
Line : Invoke-PowerBIRestMethod -Method POST -Url reports/4557598e-158d-407e-90e5-35a08b7c7584/ExportTo
Position : At line:1 char:1
+ Invoke-PowerBIRestMethod -Method POST -Url reports/4557598e-158d-407e ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 3
- Greg_Deckler6 years ago
Community Champion
Anonymous - The part that I am struggling with is getthing the authentication token. Am I missing it in the script where it explains how to do that or can you post your powershell code? I have found a number of blog articles on how to do it but they are all apparently out-of-date.
- Greg_Deckler6 years ago
Community Champion
I found the full source of the script but I get this error when trying to get the authentication token:
Method invocation failed because [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext] does not
contain a method named 'AcquireToken'. - Greg_Deckler6 years ago
Community Champion
And, I am still getting 403 forbidden when I skip the authentication piece for the app and just do it as myself. Now, I am not using a Premium workspace but I am also just trying to export as PNG which I should be allowed to do. - Greg_Deckler6 years ago
Community Champion
Anonymous Perhaps try it with PNG instead of PDF. Supposedly you do not need Premium for PNG but I still can't get it to work.
- Anonymous6 years agoNot applicable
Hi Greg_Deckler ,
I came across a blog which was very helpful to resolve the issue. Provided the blog URL below.
http://dataap.org/blog/tag/export-to-pdf-rest-api/
Thanks,
Prakash
- Anonymous6 years agoNot applicable
Hi Greg_Deckler ,
Actually I haven't tried in Premium workspace yet. I need to get permission from client to implement it in Premium workspace, once i get the permission i will let you know.
I was trying it in my local and i was getting one or more error and the below URL was somewhat helped me.
http://dataap.org/blog/tag/export-to-pdf-rest-api/
Now i am getting one error and i think it will get resolve if i try it in Premium workspace. I think that API will work only in Premium Workspace so i am getting that one error.
I am unaware of authentication token part which you were facing. I am yet to face that scenario.
Thanks and Regards,
Prakash