dmt2989
dmt2989

Reputation: 1620

How to view API response - rails

I'm trying to tie my rails app into the Zendesk API to allow customers to submit questions from a web form. After submitting a question (testing from local machine), my rails server shows the following activity:

tarted POST "/tickets" for 127.0.0.1 at 2014-01-14 09:22:11 -0800
Processing by TicketsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"blahblah", "email"=>"[email protected]", "subject"=>"asdfasdf", "body"=>"asdfasdfasdf", "commit"=>"Send Your Question"}
post https://myaccount.zendesk.com/api/v2/tickets
  Accept: "application/json"
  Accept-Encoding: "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
  User-Agent: "ZendeskAPI API 1.2.2"
{:ticket=>#<Hashie::Mash comment=#<Hashie::Mash body="asdfasdfasdf"> requester_id=455344333 subject="asdfasdf">}

Problem is, the tickets aren't posting to my Zendesk account. I'm hoping to see what the response from the API is; possibly that can help troubleshoot. What is the best way to see an API response?

Upvotes: 1

Views: 201

Answers (1)

user229044
user229044

Reputation: 239461

Consider installing the pry gem, which will let you open an interactive console wherever it is you're getting your response.

You can set a "break point" of sorts with binding.pry, and your server will drop into an REPL console (not unlike irb) where you can inspect the response.

Upvotes: 1

Related Questions