Reputation:
I am finding trouble in having Devise responding correctly to a JSON message.
the following is working fine
curl -XPOST 'http://localhost:5000/users/sign_in.json' -d 'user[email]=MYUSER' -d 'user[password]=MYPASSWORD'
Completed 201 Created in 171ms
In place, I would like to have a more proper JSON format
curl -v -b cookie.file -c cookie.file -H "Content-Type: application/json" -X POST -d '{"user":{"mail":"MYUSER","password":"MYPASSWORD"}}' http://localhost:5000/users/sign_in.json
But I does not seem to work
Processing by Devise::SessionsController#create as JSON 23:10:32 web.1 | Parameters: {"user"=>{"mail"=>"MYUSER", "password"=>"[FILTERED]"}, "session"=>{"user"=>{"mail"=>"MYUSER", "password"=>"[FILTERED]"}, "action"=>"create", "controller"=>"devise/sessions", "format"=>"json"}} 23:10:32 web.1 | Completed 401 Unauthorized in 11ms
Any ideas? thanks
Upvotes: 0
Views: 1023
Reputation:
curl -v -b cookie.file -c cookie.file -H "Content-Type: application/json" -X POST -d '{"user" : {"email":"MYUSER" , "password":"MYPASSWORD" }}' http://localhost:5000/users/sign_in.json
It is doing the job. It turn out to be a (plain) misspelling (mail in place of the correct email). Rails logs did not help me to find the solution quickly
Upvotes: 0