I am sending HTTP POST request:
data = { id: 1, name: 'ABC' }
uri = URI.parse('http://localhost:3000/events')
http = Net::HTTP.new(uri.host, uri.port)
http.post(uri, data.to_json)
My routes file:
Rails.application.routes.draw do
post '/events' => 'receiver#create'
end
Whereas create methods looks like:
def create
package = {
id: ,
name:
}
end
How can I get access to data values passing via request? My goal is to assign it to new hash within create method
params[:id]andparams[:name]?data = { package: { id: 1, name: 'ABC' } }, and in your controller try to access it simply withparams[:package]?protect_from_forgery :except => :create