由于某种原因,我陷入了简单的Invoke-WebRequest
的困境。我需要通过方法“ POST”和enc类型的“ multipart / form-data”将XML文件发送到网站。我的代码:
$SupraliftXML="C:\supralift.xml"
$Uri = 'https://www.supralift.com/servlet/EcutServlet?handler=BulkloadHandler&jfaction=0'
$Form = @{
muddledPassword = 'mypassword'
userID = 'myuserID'
XMLfile = Get-Item -Path $SupraliftXML
}
$Result = Invoke-RestMethod -AllowUnencryptedAuthentication -Uri $Uri -Method Post -Form $Form
我收到一个错误,指出没有像“ -form”这样的参数
$ Result =调用WebRequest -Uri $ Uri -Method Post -Form $ Form + CategoryInfo:InvalidArgument:(:) [Invoke-WebRequest],ParameterBindingException + FullyQualifiedErrorId:NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
谢谢您的帮助!