09-25-2012 10:00 AM
There was a question offline that I wanted to post that may be useful:
There are two formats that the user can request for responses from the REST API; JSON and XML. It was noticed by a user that even if you set the return format to XML, error messages are still generated using JSON.
This is done deliberately. There may be cases where an error gets generated where it is not possible to interpret the response format that the user wants. This means that we need to have a default format for error responses. If we allowed the user to set the format of the error reponses to something other than the default, there could be cases where error messages get generated in different formats. For example, if we allowed the user to specify XML as the error format (which is not the default), we may have cases where we are able to interpret the error response and emit an error in XML format and there may be cases where we can not and so we emit an error in the default (JSON) format. This would require a client to underdstand both.
To avoid this, we always return error messages in JSON format since that is the default format for responses with the API.