February 26, 2007, 9:02pm
If I use map.resources, Rails should automatically pull the parameters
out of the XML for me, right? Or do I have to do a slurp_params trick
http://www.railsweenie.com/forums/2/topics/709?page=6 ? Finally,
how can I test this with curl? I've tried doing stuff like:
curl -d "<video><title>foo</title></video>"
but that doesn't work. The request params show
"<video><title>foo</title></video>"=>"". That's without using
slurp_params...and when I do that, the format is url_encoded instead
So two questions.
1. Do I need to do anything special to parse XML params?
2. How can I test POSTing XML to my controller?
February 26, 2007, 9:57pm
Turns out Rails does everything automatically if you set the
curl -H "X-POST_DATA_FORMAT: xml" -d "<video><title>Mission:
Short blog post if anyone wants an easy link to share:
February 26, 2007, 10:28pm
I’m running rails 1.2.2 and don’t have to pass the X_POST_DATA_FORMAT header to get Rails to read my XML string. This is the test script I use:
It basically just sets the Accept and Content-Type headers and then puts the XML text.
Are you running these curl calls from your functional tests or from the command line (on your dev setup)?
February 26, 2007, 10:54pm
I was just running it from the command line. I just did some testing,
and setting Content-Type to application/xml is all that's needed