The company I work for have started to create RESTful services with most of the development being outsourced.
Our first service is for user authentication. When a user enters an incorrect username and password the browser receives a status code of 200 and the response body representation is:
{
    "state": "FAILED",
    "responseCode": 400,
    "timestamp": 1310378271300,
    "anies": [
        {
            "errorCode": "-6600",
            "errorType": "MSG_ERR_EMPTY_ACCOUNT_API_KEY",
            "translation": {
                            "lang": "en",
                            "value": "Provided login is empty"
                        },
            "property":"apiKey"
        },
        {
            "errorCode": "-6601",
            "errorType": "MSG_ERR_EMPTY_ACCOUNT_API_PASSWORD",
            "translation": {
                            "lang":"en",
                            "value":"Provided password is empty"
                        },
            "property": "apiPassword"
        }
    ]
}
The browser interacts with a controller which in turn calls a web service. We will have clients interacting with the services directly as well.
The representation above contains the state of failure (400), an internal error code so a client of the service can look up what the error is in a particular language and a translation of the error which the browser will use to display on screen. The "property" attribute is the form element/ parameter the error corresponds to.
This feels incorrect to me.
- Should the browser receive a status code of 400 and then look at the representation why it failed?
- Should there be a attribute for translated text or would it make sense to have the text already translated if the accept header is en, fr, etc?
- Is there anything else anyone can suggest?
Thank you
 
     
     
     
    