Reputation:
I am receiving http requests to my rails application to a url /account/postback
The body of this incoming request contains some json that I need to retrieve, how can I do this in ruby?
Upvotes: 37
Views: 42531
Reputation: 2351
If your HTTP call is using the POST verb you could alternatively use request.raw_post
to retrieve the contents sent in the request's body.
Hope it helps!
Upvotes: 9
Reputation: 30211
The following should print the body of the request
routes.rb
map.connect 'account/:action', :controller => 'accounts'
accounts_controller.rb
class AccountsController < ApplicationController
def postback
puts request.body.read
end
end
Upvotes: 69