Responses form the JSON API web service contain a list of results corresponding to each of the command that was submitted. Each result may contain either a "result" : { } pair that lists the command return values (if any), or the "errors" : [ ] pair that lists the errors returned by the command.
If an error occurs during processing a request having multiple commands, the service stops execution of further commands and sends a response object with the results of preceding commands and the error description for the current command.
The Format of Error Descriptions
The returned "errors" : [ ] pair holds an array with one or more error descriptions. Each error description has the following fields:
- "code" - Short error code, which you can use for error handling.
- "message" - More detailed description of the error. This message can be displayed to the end-users.
- "data" - Any extra data that is relevant for the particular error. This is an optional field and it may be omitted.
Sample Error Descriptions
Below are several examples of error descriptions:
- Unneeded parenthesis in command name:
[ { "errors" : [
{ "code" : "NoSuchCommand",
"message" : "The command 'ServerInfoService.getVersion()' does not exist." } ]
} ]
- Incorrect authentication:
[ { "errors" : [
{ "code" : "AuthenticationFailed",
"message" : "Could not authenticate user 'jsmith' using password provided." } ]
} ]