【发布时间】:2014-05-23 13:09:15
【问题描述】:
我正在尝试向 Jenkins 远程访问 api 发送 POST 请求,并且需要将 Content-Type 标头设置为 'application/xml' 以使请求正常工作。
我试过用.headers(Authentication: auth, Content-Type: 'application/xml') 设置它无济于事。当我传入 Content-Type 参数时,请求甚至没有通过。如果我在没有Content-Type 参数的情况下提交请求,则返回的html 包括<h1>Error</h1>No Content-Type header。
这是我尝试运行的代码:
msg.http(url)
.headers(Authorization: auth, Content-Type: 'application/xml')
.query(name: name)
.post(config_xml) (err, res, body) ->
msg.send "POSTed"
【问题讨论】:
-
msg对象是什么类型的对象,您正在调用该方法? -
是传递给hubot脚本的robot.respond函数的参数,是GitHub写的聊天机器人
-
它是 Response 对象的一个实例,在这里定义:github.com/github/hubot/blob/master/src/response.coffee
标签: html coffeescript httprequest