從Powershell第3版開始,我們有一些名爲Invoke-WebRequest。 你可以利用它的美麗,並可以完成相應的工作。
$postParams = @{host_config_key='XXXXXXXXXXXXXXXXXXXXXXXXX'}
Invoke-WebRequest -Uri https://10.XX.XXX.XXX:443/api/v1/job_templates/646/callback/ -Method POST -Body $postParams
您可以以不同的方式使用它。它有很多選項來完成工作。 用於獲取RSS提要的另一個很好的例子:
Invoke-RestMethod -Uri http://blogs.msdn.com/powershell/rss.aspx | Format-Table -Property Title, pubDate
而且,這些都是選項,你可以利用,供您參考:
Invoke-RestMethod [-Method <WebRequestMethod>] [-UseBasicParsing] [-Uri] <Uri>
[-WebSession <WebRequestSession>] [-SessionVariable <String>] [-Credential <PSCredential>]
[-UseDefaultCredentials] [-CertificateThumbprint <String>] [-Certificate <X509Certificate>]
[-UserAgent <String>] [-DisableKeepAlive] [-TimeoutSec <Int32>] [-Headers <IDictionary>]
[-MaximumRedirection <Int32>] [-Proxy <Uri>] [-ProxyCredential <PSCredential>] [-ProxyUseDefaultCredentials]
[-Body <Object>] [-ContentType <String>] [-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>]
[-PassThru] [<CommonParameters>]