I am working on the API of my web app. It is a Rails 2 app, and the REST API respond to XML.
For example, I need to return an error, in case it wasn't able to unsubscribe a contact from a list. So I respond with an Unprocessable Entity (422), with the error message in the XML. This is the actual code:
respond_to do |format|
begin
...
format.xml { head :ok }
rescue => e
format.xml { render :xml => e.to_s, :status => :unprocessable_entity }
end
end
The problem is that in the other side, when someone make a requisition using ActiveResouce the error arrives with the message empty, like this:
ActiveResource::ResourceInvalid: Failed. Response code = 422. Response message = .
Is there any XML structure or tag I need to put in the response, to the Response message don't be empty?
Thanks