我正在编写我的第一个REST程序,而且我正在努力传递会话令牌。此外,我已经在几个论坛上查找了类似的问题,但没有运气。
所以我有以下Ruby块代码(不是整个脚本):
require 'rest-client'
require 'json'
headers_lbvserver = {
'Content-Type' => application/vnd.com.citrix.netscaler.lbvserver+json',
'accept' => :json
}
add_lbvserver = RestClient::Request.execute(
:method => :post,
:url => url_lbvserver,
:headers => headers_lbvserver,
:payload => payload_lbvserver,
:cookie => {'NITRO_AUTH_TOKEN=' => token_login}
)
所以我已经收到了之前REST帖子中的令牌,但是当我第二次调用该对象时,我无法通过它。它带有以下错误:400 Bad Request(RestClient :: BadRequest)
答案 0 :(得分:0)
查看RestClient的文档后,看起来您正在宣布您的cookie不正确。您不需要在cookie名称后面加上等号:
:cookie => {'NITRO_AUTH_TOKEN=' => token_login}
应该是
:cookie => {'NITRO_AUTH_TOKEN' => token_login}