Error response handling
Describes how errors should be handled.
On error the HTTP status code is set in the response.
At least the following status codes should be handled: 400, 404, 422, 500, 502 .
The http status code MUST be checked by any application!
It is not valid to process only the response body because proxy servers may modify it.
Note: The http status code is not equal to the “code” field in the body!
All endpoints use a generic response format.
It is not valid to process only the response body because proxy servers may modify it.
Note: The http status code is not equal to the “code” field in the body!
status is always “error”
code is an integer value equal to the http status code
message is a string with a meaningful error message
Error messages are only for human interpretation.
It is not recommended to parse for specific error messages!
It is not recommended to parse for specific error messages!
Response:
{
"status": "error",
"code": <http error code(integer)>,
"message": <String>
}
Example (Not Found)
Request:
curl http://localhost/api/bmc/1.0/0/error_msg
Response:
{
"status": "error",
"code": 404,
"message": "Not Found"
}
Example (Unprocessable Entity)
Request:
curl http://localhost/api/bmc/1.0/0/buzzer --header "Content-Type: application/json" --request POST --data '{"mode": 4, "duration": 0}'
Response:
{
"status": "error",
"code": 422,
"message": "duration out of range"
}