windows - 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
我是初学者,所以我不知道具体发生了什么......
解决方案
您需要为-ContentType
. 例如,
Invoke-WebRequest -Uri www.example.com -Method POST -ContentType 'text/plain' -InFile FileNameHere
推荐阅读
- java - Java 在文本文件中搜索字符串并替换或删除字符串中的字符
- reactjs - 我将如何测试组件道具是否等于另一个道具功能?
- android - 使用查询从 firebase 检索数据
- kubernetes - 如何在 pod 中运行 systemctl
- azure - Application Insights 磁贴(表格)不会在 Azure 仪表板上自动刷新
- file - 如何创建指向本地文件的链接
- javascript - JS 延迟脚本不使用 setTimeout
- java - 如何修复在 Hive 下运行的 geoip2 java 的“java.lang.NoSuchMethodError”
- r - 尝试使用 ggplot 制作具有多条线的图形
- jquery - $.each 没有遍历所有来自 ajax 响应的对象