首页 > 解决方案 > PowerShell Invoke-WebRequest 产生 422 不可处理的实体?

问题描述

我在 powershell 中的 Windows 10 上运行该命令。

命令如下

Invoke-WebRequest -Uri www.example.com -Method POST -InFile FileNameHere

我得到的错误是

+ Invoke-WebRequest -Uri "www.example.com ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest],WebExce
    ption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

我是初学者,所以我不知道具体发生了什么......

标签: windowspowershell

解决方案


您需要为-ContentType. 例如,

Invoke-WebRequest -Uri www.example.com -Method POST -ContentType 'text/plain' -InFile FileNameHere

推荐阅读