HTTParty's parsed_response
method returns a Hash if you get a response code 200 but otherwise it will return a String regardless if the webserver returns a XML response.
HTTParty.get(post_url).parsed_response.class # Depends on response code
Amazon will provide XML (explaining what went wrong) even on a 403.
Am I missing something?
HTTParty parses its #parsed_response
based on what the HTTP response's Content-Type
header is. Verify what the value is for that HTTP header. In your case, you'd want it to be application/xml
.
In case anyone is still encountering this issue today, get
can take a format parameter, which can help you ensure your HTTParty::Response
object is a Hash:
url = HTTParty.get('http://domain.com', format: :json) # class is a Hash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With