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 information is usually returned in the response body.
HTTP Response Status Code is 200 on all successful responses. Other possible status codes are described in the table below. Additional status codes depend on the method.
| STATUS CODE | CONDITION |
|---|---|
| 200 | Successful request. |
| 400 | Missing or invalid request parameters, invalid Authorization header, unsupported HTTP method (some methods), etc. |
| 401 | Missing Authorization header (some methods return 403 with NO_AUTH or INVALID_AUTH instead). |
| 403 | Invalid Credentials, Unencrypted connection, etc. |
| 404 | Not Found (e.g. invalid property or room code, or an HTTP method the endpoint does not support) |
| 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
}
Some errors, such as a missing Authorization header on some methods or an HTTP method the endpoint does not support, are returned without this JSON body. Always check the HTTP Response Status Code first.
Error codes vary by method and new codes may be added at any time. Handle unknown error_code values based on http_code.
| ERROR_CODE | HTTP_CODE | DESCRIPTION |
|---|---|---|
| OK | 200 | The request completed successfully. |
| NO_HOTELS_FOUND | 200 | No properties found in specified location. |
| NO_RATES_FOUND | 200 | No rates found for the specified property and filters. |
| INVALID_METHOD | 400 | Method requested is not supported (e.g. POST is not supported, use GET). Returned by some methods only. |
| INVALID_PARAM | 400 | When missing or invalid request parameters are passed. Check the error_msg for details. |
| BAD_REQUEST | 400 | The request cannot be processed as sent. 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. Returned by some methods only. |
| NO_AUTH | 403 | No authentication header found. Returned by some methods only. |
| INVALID_AUTH | 403 | Invalid username or password. Some methods also return it for missing or malformed credentials, or for an account type the method does not support. |
| FORBIDDEN | 403 | The credentials are invalid. |
| ACCOUNT_DISABLED | 403 | The API account has been deactivated. |
| ACCOUNT_EXPIRED | 403 | The API account has expired. |
| IP_NOT_ALLOWED | 403 | The request was sent from an IP address that is not allowed for the API account. |
| NO_PRIVILEGES | 403 | The API account is valid but cannot use the requested method. |
| NOT_ALLOWED | 403 | The requested action is not allowed for this account or resource. Some methods return a different http_code. |
| NOT_FOUND | 404 | The requested resource was not found (e.g. invalid property or room code). |
| 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. |