【发布时间】:2011-05-05 15:16:27
【问题描述】:
我在 Windows 上,对 URI 执行 POST 操作的最简单、最快的方法是什么?我可以使用命令行或 PowerShell 来实现吗?
【问题讨论】:
标签: windows http command-line powershell http-post
我在 Windows 上,对 URI 执行 POST 操作的最简单、最快的方法是什么?我可以使用命令行或 PowerShell 来实现吗?
【问题讨论】:
标签: windows http command-line powershell http-post
Powershell 示例:
$c=New-Object System.Collections.Specialized.NameValueCollection
$c.Add('param1','value1')
$c.Add('param2','value2')
$wc = New-Object system.net.webclient
$d = $wc.uploadvalues("http://your.url",$c)
【讨论】:
这现在是 PowerShell 3.0 版以来的本机:
Invoke-WebRequest -method POST -uri http://somewhere.com/rest/sample -body $content
别名为iwr、wget 和curl。
省去了创建WebClient 对象的所有麻烦。
根据Wikipedia:
PowerShell 3.0 与 Windows 8 和 Windows Server 2012 集成。Microsoft 还为带有 Service Pack 1 的 Windows 7、带有 Service Pack 1 的 Windows Server 2008 以及带有 Service Pack 1 的 Windows Server 2008 R2 提供了 PowerShell 3.0 .
【讨论】: