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 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>" http://localhost:3001/videos.xml 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 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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 2/26/07, Pat Maddox <pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 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>" http://localhost:3001/videos.xml > > 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 > 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 "<video><title>Mission: Impossible</title></video>" http://localhost:3000/videos Short blog post if anyone wants an easy link to share: http://evang.eli.st/blog/2007/2/26/posting-xml-to-your-restful-controller Pat --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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, Pat Maddox <pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 2/26/07, Pat Maddox <pergesu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > 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 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>" > http://localhost:3001/videos.xml > > > > 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 > > 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 "<video><title>Mission: > Impossible</title></video>" http://localhost:3000/videos > > Short blog post if anyone wants an easy link to share: > http://evang.eli.st/blog/2007/2/26/posting-xml-to-your-restful-controller > > Pat > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 2/26/07, Ed Hickey <bassnode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > 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)?edI 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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---