Below code I m using to export pdf.When i pass direct value value in line 5 then its working but when i m pass $id in line 5,it snot working.
1 $uri = "https://api.powerbi.com/v1.0/myorg/reports/$Report_ID/ExportTo"
2 $body = "{"format
":"pdf
"}"
3 $FileExport = Invoke-RestMethod -Uri $uri –Headers $auth_header –Method POST -body $body
4 $id = $FileExport.id
5 $uri = "https://api.powerbi.com/v1.0/myorg/reports/$Report_ID/exports/$id/file"
6 Invoke-RestMethod -Method GET -Uri $uri –Headers $auth_header -OutFile "\Desktop\PDF\test.pdf"
Below error
*Invoke-RestMethod : The remote server returned an error: (400) Bad Request. At line:79 char:2
- Invoke-RestMethod -Method GET -Uri $uri –Headers $auth_header -OutFi ...
-
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand*