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 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 On 16 August 2010 06:32, MarkB <mark_balch-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> 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 > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thank you so much, Mickael. This is indeed what I was missing. Much appreciated. Mark On Aug 15, 11:36 pm, Mickael Gerard <mika...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > > On 16 August 2010 06:32, MarkB <mark_ba...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: > > > > > 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 > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.- Hide quoted text - > > - Show quoted text --- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.