【问题标题】:Hudson Remote API gives 400 error when Invoke-RestMethod POST called from Powershell v3从 Powershell v3 调用 Invoke-RestMethod POST 时,Hudson Remote API 给出 ​​400 错误
【发布时间】:2013-11-26 10:53:27
【问题描述】:

我想编写使用 Powershell(Hudson 版本 3.0.1-b2)创建 Hudson 作业的脚本。从Configure or Create hudson job automaticallyhttp://technet.microsoft.com/en-us/library/hh849971.aspx (Invoke-RestMethod) 看起来这应该很容易。但是,我是一个 powershell 初学者:

Invoke-RestMethod -Uri "http://localhost:hudsonPort/createItem?name=jobName" -Body config.xml -Method Post -ContentType "text/xml"

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

无论哪种方式,我都会收到 400 错误请求错误。请求有什么问题?我觉得挺好看的。

【问题讨论】:

    标签: rest powershell hudson


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-04
      • 1970-01-01
      • 2012-02-26
      • 1970-01-01
      • 1970-01-01
      • 2017-01-12
      相关资源
      最近更新 更多