Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing XML posts not working? #199

Open
kelfink opened this issue May 15, 2015 · 4 comments
Open

Parsing XML posts not working? #199

kelfink opened this issue May 15, 2015 · 4 comments

Comments

@kelfink
Copy link

kelfink commented May 15, 2015

In Rails 4.2.1, I added
config.middleware.insert_after ActionDispatch::ParamsParser, ActionDispatch::XmlParamsParser

to my Application in application.rb

But my XML post still isn't getting parsed. I put debugger lines in the initializers for XmlParamsParser and for the core ParamsParser. Both initializers are called (probably from the line I added) but neither one's "call" is ever called. And of course, by XML body isn't being parsed, either, as far as I can tell. Do I have to do this manually, instead? Hash.from_xml ?

First Rails 4.2.1 project, and first time with rails-api, so most likely I'm doing it wrong....

TIA

@edgibbs
Copy link

edgibbs commented May 18, 2015

+1

@kelfink
Copy link
Author

kelfink commented May 19, 2015

Ah. Problem mostly solved. Looks like it's working when Rails is fully running. I was trying to see the XML in a post get parsed when in an spec unit test. Something seems to be skipping the params parser and xml parser. Maybe for speed? Anyone know if it can be enabled, so I'm testing original API input ? From a unit test perspective, I don't mind shifting my post to use a hash. It was just confusing.

@ttcremers
Copy link

+1

@sunloverz
Copy link

Add this gem https://github.com/rails/actionpack-xml_parser and include the following into application.rb

  config.middleware.use ActionDispatch::XmlParamsParser
  config.api_only = false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants