简体   繁体   English

Power BI Powershell 导出到 PDF 脚本不工作

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

Below code I m using to export pdf.When i pass direct value value in line 5 then its working but when im pass $id in line 5,it snot working.在下面的代码中,我使用导出 pdf。当我在第 5 行传递直接值时,它会工作,但是当我在第 5 行传递 $id 时,它不会工作。

1 $uri = "https://api.powerbi.com/v1.0/myorg/reports/$Report_ID/ExportTo" 1 $uri = "https://api.powerbi.com/v1.0/myorg/reports/$Report_ID/ExportTo"

2 $body = "{ "format ": "pdf "}" 2 $body = "{ "format ": "pdf "}"

3 $FileExport = Invoke-RestMethod -Uri $uri –Headers $auth_header –Method POST -body $body 3 $FileExport = Invoke-RestMethod -Uri $uri –Headers $auth_header –方法 POST -body $body

4 $id = $FileExport.id 4 $id = $文件导出.id

5 $uri = "https://api.powerbi.com/v1.0/myorg/reports/$Report_ID/exports/$id/file" 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" 6 调用-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. *Invoke-RestMethod:远程服务器返回错误:(400)错误请求。 At line:79 char:2在行:79 字符:2

  • Invoke-RestMethod -Method GET -Uri $uri –Headers $auth_header -OutFi...调用-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"

This is a string, you have to break it up or it will be read literally as part of the string.这是一个字符串,您必须将其分解,否则它将被逐字地读取为字符串的一部分。

$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