【发布时间】:2015-04-15 13:18:48
【问题描述】:
我正在使用rest-client gem 尝试向我的 API 发帖。
RestClient.post 帮助器需要三个参数来传递这样的标头:.post(url, params, headers)。您是否尝试过类似的方法?
RestClient.post('http://api.example.com/', {key: 'value'}, 授权: 'a2m...')
https://github.com/rest-client/rest-client/issues/339#issuecomment-71787018
我已遵循上述建议,但收到 RestClient::Unauthorized - 401 Unauthorized 作为回复。
我的代码:
RestClient.post "http://api.example-dev.com:7000/v1/resources", {key: 'value'}, :authorization => 'yyyyyyyy'
我用下面的 curl 命令成功了,但上面的 RestClient.post 没有。卷曲成功:
curl -i -X POST -d 'test[key]=1234' -H "Authorization: Token token=yyyyyyyyyyyyyy" \ http://api.example-dev.com:7000/v1/resources
【问题讨论】:
标签: rest-client