はここでPowerShellのバージョン2(使用して.NETクラスSystem.Net.HttpWebRequest)と私のREST呼び出し(PUT)残りの呼び出しは
は、コールが持っているですbodyというXMLファイルであり、PowerShellのバージョン3以降では、 "Body"というプロパティを持つinvoke-WebRequestを使用してこの作業を行うことができます。しかし、私はいくつかのPowerShellバージョン2システムを持っているので、.netクラスでこれを行う必要があります。以下は
同じことが「0」の引数(複数可)と「GetRequestStream」を呼び出し、エラー例外で失敗した私のコード
$psuri = "$restUri"
[string]$psdata = Get-Content -path "$myfile.xml"
[System.Net.HttpWebRequest]$global:ps = [System.Net.HttpWebRequest] [System.Net.WebRequest]::Create("$psuri");
$psbuffer = [System.Text.Encoding]::UTF8.GetBytes($psdata)
$ps.ContentLength = $psdata.length
$ps.ContentType = "application/xml"
[System.IO.Stream]$outputStream = [System.IO.Stream]$ps.GetRequestStream()
$outputStream.Write($psdata, 0, $psbuffer.Length)
$ps.method = "PUT"
$ps.Accept = "application/xml"
$ps.AllowAutoRedirect = $false
$ps.KeepAlive = $true
$ps.CookieContainer = $CookieContainer
$ps.PreAuthenticate = $true
#Try
#{
[System.Net.HttpWebResponse]$psresponse = $ps.GetResponse()
です:「この動詞形でコンテンツボディを送信できません」行:8文字:9