How to debug/display request sent using RestClient

If you're doing more of a REPL kind of development, it can be as easy as adding

RestClient.log = 'stdout'

to your code.

You can find other valid values in the docs.


In case you don't know (or want to bother) to pass in env. variable to your app (in my case it was Passenger/Rails), do something similar:

$ cat >/usr/share/foreman/config/initializers/00_rest_client.rb <<'EOT'
require 'rest_client'
RestClient.log =
  Object.new.tap do |proxy|
    def proxy.<<(message)
      Rails.logger.info message
    end
  end
EOT

You could try enabling RestClient's logging and see whether this provides any useful output:

RESTCLIENT_LOG=stdout path/to/my/program

or if you are using Rails

RESTCLIENT_LOG=stdout bundle exec passenger

replacing passenger with your choice of server. This will redirect all logging to standard output (your console).

Personally I prefer using more verbose tools when I need to inspect or troubleshoot HTTP requests.

You could try curl or wget if you prefer command-line, or one of the many browser extensions which let you perform requests easily, inspect output, save for future use, set up different environments etc. Both Postman and Advanced REST Client are good choices.