簡體   English   中英

Power BI Powershell 導出到 PDF 腳本不工作

[英]Power BI Powershell Export to PDF Script not Working

在下面的代碼中,我使用導出 pdf。當我在第 5 行傳遞直接值時,它會工作,但是當我在第 5 行傳遞 $id 時,它不會工作。

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 –方法 POST -body $body

4 $id = $文件導出.id

5 $uri = "https://api.powerbi.com/v1.0/myorg/reports/$Report_ID/exports/$id/file"

6 調用-RestMethod -Method GET -Uri $uri –Headers $auth_header -OutFile "\Desktop\PDF\test.pdf"

低於錯誤

*Invoke-RestMethod:遠程服務器返回錯誤:(400)錯誤請求。 在行:79 字符:2

  • 調用-RestMethod -Method GET -Uri $uri –Headers $auth_header -OutFi ...
  •  + CategoryInfo: InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException + FullyQualifiedErrorId: WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand*

$uri = "https://api.powerbi.com/v1.0/myorg/reports/$Report_ID/exports/$id/file"

這是一個字符串,您必須將其分解,否則它將被逐字地讀取為字符串的一部分。

$uri = "https://api.powerbi.com/v1.0/myorg/reports/" + $Report_ID + "/exports/" + $id + "/file"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM