POSTing XML - how do I test that?

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
like RailsNotes — The Ruby on Rails guides you wished you had. ? Finally,
how can I test this with curl? I’ve tried doing stuff like:

curl -d “
http://localhost:3001/videos.xml

but that doesn’t work. The request params show
”=>“”. That’s without using
slurp_params…and when I do that, the format is url_encoded instead
of xml.

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?

Thanks,
Pat

On 2/26/07, Pat M. [email protected] wrote:

of xml.

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?

Thanks,
Pat

Turns out Rails does everything automatically if you set the
X-POST_DATA_FORMAT header.

curl -H “X-POST_DATA_FORMAT: xml” -d “http://localhost:3000/videos

Short blog post if anyone wants an easy link to share:

Pat

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:
http://snippets.dzone.com/posts/show/3521

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)?
ed

On 2/26/07, Ed Hickey [email protected] wrote:

command line (on your dev setup)?ed
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
apparently. Thanks.

Pat