调用 Web 请求抛出错误:Invoke-WebRequest : {“errors”:[]}

发布于 2025-01-14 10:03:08 字数 823 浏览 6 评论 0原文

我正在使用 powershell 脚本通过 invoke-webrequest 从网站获取详细信息。通过使用凭据,我使用 invoke-restmethod 连接到网站来获取令牌。 获取令牌后,我使用该令牌通过调用 webrequest 检索我需要的详细信息。但随后它会以这种方式抛出错误。URL 工作正常。

“Invoke-WebRequest:{“错误”:[]}”

我怎样才能知道这个请求有什么问题。 API查询:

Invoke-WebRequest -Headers @{"X-Token" = "$token"} -Method Get -Uri "$URL"

错误信息:

Invoke-WebRequest : {"errors":[]} At C:\temp\RTPA\rtpa_vault3.ps1:24 char:24
+ ... ltdetails = Invoke-WebRequest -Headers @{"X-Token" = "$tok ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

I am using a powershell script to get details from a website via invoke-webrequest. By using the credentials i have connecting to the website using invoke-restmethod to get the token.
After getting the token i used the token to retrieve the details that i need by using invoke-webrequest. But then it is throwing the error this way.The URL is workingfine.

"Invoke-WebRequest : {"errors":[]}"

How can i get to know what is the problem with this request.
API Query:

Invoke-WebRequest -Headers @{"X-Token" = "$token"} -Method Get -Uri "$URL"

error message:

Invoke-WebRequest : {"errors":[]} At C:\temp\RTPA\rtpa_vault3.ps1:24 char:24
+ ... ltdetails = Invoke-WebRequest -Headers @{"X-Token" = "$tok ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文