Skip to content
Last updated

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 membershipId parameter does not meet the expected format.
  • Missing required fields in the request body.

How to Handle:

  1. Validate input parameters before sending the request.
  2. Reformat the membershipId to 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 Authorization header.
  • Expired or incorrect API token.

How to Handle:

  1. Ensure the token is included in the Authorization header.
  2. 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 reservationId does not exist in the system.
  • Incorrect endpoint URL.

How to Handle:

  1. Double-check the reservationId parameter.
  2. 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:

  1. Retry the request after a short delay.
  2. 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.