以下请求有什么问题?
request = Typhoeus::Request.new("http://fluidsurveys.com/api/v2/groups",
method: :get,
userpwd: "test_user:test_password",
headers: { 'ContentType' => "application/json"})
response = request.body
puts response
这返回undefined method body for #<Typhoeus::Request:0x007f8e50d3b1d0> (NoMethodError)
以下请求适用于httparty
:
call= "/api/v2/groups/"
auth = {:username => "test_user", :password => "test_password"}
url = HTTParty.get("http://fluidsurveys.com/api/v2/groups",
:basic_auth => auth,
:headers => { 'ContentType' => 'application/json' } )
response = url.body
puts response
编辑:
我试过这个:
response = request.response
puts response.body
没有运气。我收到这个:undefined method body for nil:NilClass (NoMethodError)