Search code examples
ruby-on-railsrubyhttparty

HTTParty doesn't print response


What am I doing wrong? I'm connecting to an external API:

class Shipup
  include HTTParty
  base_uri ENV['SHIPUP_URL']

  def initialize
    @options = { }
  end

  def sendTracker(tracker)
    self.class.post("/trackers", @options.merge!({
      body: {
        trackers: [tracker]
      }
    }))
  end
end

puts Shipup.new().sendTracker({...})

it doesn't print out anything either if it succeeds or fails.


Solution

  • In fact, it parsed the body which is an empty string in this case. If you need other response information, it is accessible like so:

    puts response.body, response.code, response.message, response.headers.inspect