我试图运行一个PowerShell代码来调用webrequest但是我得到了一个错误
"Exception calling "Create" with "1" argument(s): "Invalid URI: The hostname could not be parsed."
我的代码如下,当我运行它时,它给我上面的错误,我在powershell v2的上下文中执行脚本。
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$wname = "101.172.171.149"
$uuid = "f7c89b32-21a0-4a6f-80b2-b6d8bb33b1c7"
[string]$URI = "https://$wname/rest/wflows/$uuid/jobs"
$request = [System.Net.HttpWebRequest]::Create($uri)
$request.Credentials = $credential
$request.CookieContainer = New-Object System.Net.CookieContainer
$request.ContentType = "application/xml; charset=utf-8"
$request.Method = "Post"
$request.keepAlive = $false
$requestStream = $request.GetRequestStream()
$streamWriter = New-Object System.IO.StreamWriter($requestStream)
$streamWriter.Write($body)
$streamWriter.flush()
$streamWriter.close()
$responseStream = $response.GetResponseStream()
$stream = new-object System.IO.StreamReader $responseStream
$xmlDump = $stream.ReadToEnd()
$output = [xml]$xmlDump
$response.close()