How to debug/display request sent using RestClient

user3075906 picture user3075906 · May 5, 2014 · Viewed 22.3k times · Source

I am trying to use RestClient to access a webservice using post method. I am sending the authorization token as specified but I am still getting a 403 status error which means I am forbidden to use that api. Is there any way that I can see the request being sent with http post so that I can verify the headers? I am not able to find any example or any documentation which mentions as to how to do that?

My code is similar to this :

token = get_token

response = RestClient.post "https://api-dev.xxx.com/software/services/search/ABC",
  :authorization => "Bearer #{token}"

Answer

Marius Butuc picture Marius Butuc · Aug 11, 2015

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.