从Powershell v3调用RestMethod POST时,Hudson Remote API出现400错误

从Powershell v3调用RestMethod POST时,Hudson Remote API出现400错误,rest,powershell,hudson,Rest,Powershell,Hudson,我想用Powershell(Hudson版本3.0.1-b2)编写Hudson作业的创建脚本。看起来这应该很容易,从和(调用RestMethod)。但请注意,我是一个powershell初学者: Invoke-RestMethod -Uri "http://localhost:hudsonPort/createItem?name=jobName" -Body config.xml -Method Post -ContentType "text/xml" 在浏览器中,localhost:huds

我想用Powershell(Hudson版本3.0.1-b2)编写Hudson作业的创建脚本。看起来这应该很容易,从和(调用RestMethod)。但请注意,我是一个powershell初学者:

Invoke-RestMethod -Uri "http://localhost:hudsonPort/createItem?name=jobName" -Body config.xml -Method Post -ContentType "text/xml"
在浏览器中,localhost:hudsonPort将我带到Hudson,我正在包含config.xml的目录中运行上述命令,config.xml是现有Hudson作业的配置文件。我还尝试预先使用
$body=cat config.xml
准备body参数,并将其提供给Invoke RestMethod命令


不管怎样,我都会收到一个400错误的请求。这个请求怎么了?我觉得它很不错。

我认为您需要提供XML文件的内容,例如
-Body(Get Content config.XML-Raw)