Error Handling
This page provides a comprehensive guide to handling errors returned by the Roomex PMS API. Each error includes an explanation, probable causes, and example code for resolving it in various programming languages.
Overview of Error Handling
The Roomex PMS API uses standard HTTP status codes to indicate the success or failure of API requests. The most common error categories are:
- 400 (Bad Request): The request could not be understood or was missing required parameters.
- 401 (Unauthorized): Authentication failed or the user does not have permissions.
- 404 (Not Found): The requested resource could not be found.
- 500 (Internal Server Error): An unexpected error occurred on the server.
Error Categories
1. Validation Errors (400 Bad Request)
Description: Occurs when the input parameters are invalid or missing.
Example Error Response:
{
"errorCode": "INVALID_INPUT",
"message": "The membershipId format is invalid."
} Probable Causes:
- The
membershipIdparameter does not meet the expected format. - Missing required fields in the request body.
How to Handle:
- Validate input parameters before sending the request.
- Reformat the
membershipIdto match the expected structure.
2. Authentication Errors (401 Unauthorized)
Description: Occurs when the API key or token is invalid, expired, or missing.
Example Error Response:
{
"errorCode": "UNAUTHORIZED",
"message": "Invalid API token provided."
} Probable Causes:
- Missing
Authorizationheader. - Expired or incorrect API token.
How to Handle:
- Ensure the token is included in the
Authorizationheader. - Refresh the token if it has expired.
3. Resource Not Found (404 Not Found)
Description: Occurs when the requested resource does not exist.
Example Error Response:
{
"errorCode": "NOT_FOUND",
"message": "Reservation ID not found."
} Probable Causes:
- The
reservationIddoes not exist in the system. - Incorrect endpoint URL.
How to Handle:
- Double-check the
reservationIdparameter. - Ensure the endpoint URL is correct.
4. Internal Server Errors (500 Internal Server Error)
Description: Occurs when the API encounters an unexpected issue.
Example Error Response:
{
"errorCode": "INTERNAL_ERROR",
"message": "An unexpected error occurred. Please try again later."
} Probable Causes:
- Temporary server issue.
- Unhandled exception on the server.
How to Handle:
- Retry the request after a short delay.
- Contact support if the issue persists.
General Best Practices for Error Handling
- Log Errors: Always log error details to help with debugging.
- Implement Retries: Use exponential backoff for retrying requests.
- Graceful Failures: Provide fallback options or friendly error messages.
- Documentation: Always refer to the latest API documentation for error codes and responses.