Guidelines for detecting and handling errors
The simplest way to detect and handle an error is by inspecting the HTTP Response Status Code of each request. Additional and more detailed error informations are usually returned in the response body.
HTTP Response Status Code is 200 on all successful responses. Other possible status codes are described on the table below. Additional status codes depend on the method.
STATUS CODE | CONDITION |
---|---|
200 | Successful request. |
403 | Invalid HTTP Method, Invalid Credentials, Unencrypted connection, etc. |
404 | Not Found (e.g. invalid property or room code) |
503 | Unknown error or temporary unavailability |
500 | All other invalid requests or responses. Described by error_code |
A sample error response can be seen below. The nature of the error encountered is described by error_code and error_msg in human-readable format, while http_code will always reflect the HTTP Response Status Code.
{
params: []
http_code: 404
error_msg: "Property not found."
error_code: "NOT_FOUND"
http_method: "GET"
method: https://rest.reserve-online.net/property/nonexisting
}
ERROR_CODE | HTTP_CODE | DESCRIPTION |
---|---|---|
OK | 200 | The request completed successfully. |
NO_HOTELS_FOUND | 200 | No properties found in specified location. |
INVALID_METHOD | 400 | Method requested is not supported (e.g. POST is not supported, use GET). |
INVALID_PARAM | 400 | When missing or invalid request parameters are passed. Check the error_msg for details. |
ZERO_RESULTS_GEO | 400 | Location not found (returned by our Geocoding provider). |
NOT_ALLOWED_GEO | 400 | Geocoding query for country/continent is not allowed. |
NO_AUTH | 403 | No authentication header found. |
INVALID_AUTH | 403 | Invalid username or password. |
FORBIDDEN | 403 | The credentials are invalid. |
INTERNAL_ERROR | 500 | Internal service error. This is usually an outage of an internal service or a bug in our code and we will be notified immediately. |
ERROR_GEO | 500 | Invalid geocoding query |