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</
password><sub_categories
type=\"array\"><sub_category>1</
sub_category><sub_category>2</sub_category></sub_categories></
subscriber>" http://localhost:3000/subscribers/helper.xml
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?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---