I\'m working on my first Sinatra app and I have an hard time getting parameters from a post request.
I\'m using MiniTest::Spec and my spec looks like
pa
Sinatra just doesn't parse this data, because they are not form parameters.
Form parameter would look like this
curl -X POST 127.1:4567/ -d "foo=bar"
Instead of params you can just use request.body.read
or use rack contrib.
rack-contrib
gem install rack-contrib
require 'rack'
require 'rack/contrib'
use Rack::PostBodyContentTypeParser
with this you can use params
as normal for json post data. Something like this:
curl -X POST -H "Content-Type: application/json" -d '{"payload":"xyz"}' 127.1:4567/
source for this: Sinatra controller params method coming in empty on JSON post request, http://jaywiggins.com/2010/03/using-rack-middleware-to-parse-json/