This page provides a comprehensive guide to handling errors returned by the PMS API. Each error includes an explanation, probable causes, and example code for resolving it in various programming languages.
The PMS API uses standard HTTP status codes to indicate the success or failure of API requests. The most common error categories are:
- 201 (Success): A successful response with no body.
- 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.
Description: Occurs when the input parameters are invalid or missing.
Example Error Response:
"status": 400,
"detail": "Errors occurred while processing the request.",
"errors": [
{
"name": "roomNumber",
"reason": "RoomNumberConflict - The room you are trying to check in is already occupied with a guest from a different company. Please verify the room number and resubmit."
}
]Probable Causes:
- Missing required fields in the request body.
How to Handle:
Validate input parameters before sending the request.
Description: Occurs when the API key or token is invalid, expired, or missing.
Example Error Response:
{
"message": "Unauthorized"
}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.
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.
- 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.