Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean type parameter not working #87

Open
ricardovsilva opened this issue May 17, 2018 · 1 comment
Open

Boolean type parameter not working #87

ricardovsilva opened this issue May 17, 2018 · 1 comment

Comments

@ricardovsilva
Copy link

If I try

patch '/:id' do |id|
    content_type :json
    param :foo, Boolean, required: true
  end

And try to do a patch passing as body:

{
  "foo": true
}

It raises 400 error. Am I doing anything wrong?

@jtara
Copy link

jtara commented Aug 28, 2018

It doesn't decode JSON by default. Just query parameters and application/x-www-form-urlencoded in body.

From the README:

Use sinatra-param in combination with Rack::PostBodyContentTypeParser and Rack::NestedParams to automatically parameterize JSON POST bodies and nested parameters.

Sorry, I haven't tried that. There is another Issue asking for particulars. #89

You should go visit the documentation for Rack::PostBodyContentTypeParser and Rack::NestedParams.

I gather that Rack::PostBodyContentTypeParser reads JSON body and adds to params.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants