The 422 unprocessable_entity appears to be limited to the "save"
operations. It would be nice that it is not limited to saves. It
would be nice to use status codes, other than 200, to display
errors from the body so we know what was wrong with our get
request.
For instance, if I did this:
[code] person = Person.find(:all, :params
=> {:first_name => "John"})
[/code]
The API server may require a combination of both :first_name and
:last_name to work so the error message would show that the last
name is a required field before the find operation can be processed
hence the unprocessable_entity used. It is able to raise 422
however the response body is not being picked up other than the
save operations.
It would be nice if the following code
(activeresource/lib/active_resource/custom_methods.rb) in
ActiveResource project shows:
[code] def put(method_name, options = {},
body = '')
begin
connection.put(custom_method_element_url(method_name, options), body, self.class.headers)
rescue ResourceInvalid => error
errors.from_xml(error.response.body) # need to also handle JSON requests as well
end self end
[/code]
Hope that can be considered!
Thanks much,
Chad