I'm doing an HTTP post to my controller with an xml request body:
curl -u 53b2c:X -H "Content-Type: text/xml" -v -d "<subscriber><full_name>Alex Egg</full_name><carrier_id>2</ carrier_id><mobile_phone>1234321843</mobile_phone><password>asdf</
<sub_categories type=\"array\"><sub_category>1</
sub_category><sub_category>2</sub_category></sub_categories></
Rails deserialized xml xml into a subscriber hash:
Parameters: {"subscriber"=>{"carrier_id"=>"2", "sub_categories"=>["1", "a"], "full_name"=>"Alex Egg", "password"=>"asdf", "mobile_phone"=>"1234321843"}, "format"=>"xml", "action"=>"helper", "controller"=>"subscribers"}
However, if I do the same post with a JSON body, it fails to find anything in the body:
curl -u 53b2c:X -H "Content-Type: application/json" -v -d '{"subscriber":{"carrier_id":2, "full_name":"alex egg", "mobile_phone":"7605554311", "password":"asdf", "sub_categories": [1,2]}}' http://localhost:3000/subscribers/helper.json
Parameters: {"format"=>"json", "action"=>"helper", "controller"=>"subscribers"}
And I get this back in the response:
[["carrier_id", "can't be blank"], ["full_name", "can't be blank"], ["mobile_phone", "can't be blank"], ["mobile_phone", "is too short (minimum is 10 characters)"]]
Shouldn't rails be able to deserialize the JSON body?