Search code examples
rubylogginghttprequesthttparty

httparty: how to log request?


How do I log requests being sent with with httparty?

HTTParty.post(
          @application_url,
          :headers => {
            "Accept"        => "application/json",
            "Content-Type"  => "application/json; charset=utf-8"
          },
          :body => {
            "ApplicationProfileId" => application.applicationProfileId
          }.to_json
        )

Solution

  • 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)