Parse XML post as parameters hash

I am trying to add a controller method that will take an XML post with
a schema not related to an existing model and parse it as a hash of
parameters. I create apis_controller.rb:

class ApisController < ApplicationController
  def create
    puts "**** API INVOKED ****"
    puts params[:name]
  end
end

Then...

curl --data-urlencode "<name>Foo</name>" -H "Content-Type:application/
xml" http://localhost:3000/apis.xml

I get the following error:

  Status: 500 Internal Server Error
  undefined method `name' for nil:NilClass

Is there a way for "puts params[:name]" to display "Foo" upon
receiving the XML post?

Thanks in advance!
Mark

Hello,

Your parameters are not seen as xml content.

You should put your xml content on a file an send it with : curl -d @file_to_send

In this case you will automatically get your xml as a map on the params map.

Mickael

Thank you so much, Mickael. This is indeed what I was missing. Much
appreciated.

Mark