httparty: how to log request?
Use debug_output at the class level: class Foo include HTTParty debug_output $stdout end or per request response = HTTParty.post(url, :body => body, :debug_output => $stdout)
Use debug_output at the class level: class Foo include HTTParty debug_output $stdout end or per request response = HTTParty.post(url, :body => body, :debug_output => $stdout)
In the latest HTTParty, you can use the verify option to disable SSL verification; HTTParty.get( “#{ @settings.api_server }#{ url }”, :verify => false ).parsed_response
Use Strings for your hash keys instead of Symbols. query = { “method” => “neworder”, “nonce” => 1404996028, “order_type” => “buy”, “quantity” => 1, “rate” => 1 } headers = { “key” => “8781974720909019987”, “sign” => “0a3888ac7f8e411ad73a0a503c55db70a291bfb9f9a47147d5200882674f717f6ede475669f3453” } HTTParty.post( “https://www.acb.com/api/v2/market/LTC_BTC/”, :query => query, :headers => headers ) It was probably only the headers that were … Read more
An instance of HTTParty::Response has a code attribute which contains the status code of the HTTP response. It’s given as an integer. So, something like this: response = HTTParty.get(‘http://twitter.com/statuses/public_timeline.json’) case response.code when 200 puts “All good!” when 404 puts “O noes not found!” when 500…600 puts “ZOMG ERROR #{response.code}” end
auth = {:username => “test”, :password => “test”} @blah = HTTParty.get(“http://twitter.com/statuses/public_timeline.json”, :basic_auth => auth)
I solved this by adding .to_json and some heading information @result = HTTParty.post(@urlstring_to_post.to_str, :body => { :subject => ‘This is the screen name’, :issue_type => ‘Application Problem’, :status => ‘Open’, :priority => ‘Normal’, :description => ‘This is the description for the problem’ }.to_json, :headers => { ‘Content-Type’ => ‘application/json’ } )