Common Errors
When working with an API OMS, you may encounter various error codes. Understanding these codes can help you diagnose and troubleshoot issues effectively. Here are some common error codes you might encounter:
Common HTTP Status Codes
1xx Informational Responses
- 100 Continue: The server has received the request headers and the client should proceed to send the request body.
2xx Success
- 200 OK: The request was successful, and the server returned the requested data.
- 201 Created: The request was successful, and a new resource was created.
- 204 No Content: The request was successful, but there is no content to return.
3xx Redirection
- 301 Moved Permanently: The resource has been moved to a new URL permanently.
- 302 Found: The resource has been temporarily moved to a different URL.
4xx Client Errors
400 Bad Request: The server could not understand the request due to invalid syntax.
- Example Causes: Missing required parameters, invalid JSON format.
- Example Response:
{ "error": "Bad Request", "message": "Required field 'order_id' is missing." }
401 Unauthorized: Authentication is required and has failed or has not yet been provided.
- Example Causes: Missing or invalid API key, expired token.
- Example Response:
{ "error": "Unauthorized", "message": "Invalid API key." }
403 Forbidden: The client does not have access rights to the content.
- Example Causes: Insufficient permissions, restricted resource.
- Example Response:
{ "error": "Forbidden", "message": "You do not have permission to access this resource." }
404 Not Found: The server cannot find the requested resource.
- Example Causes: Incorrect endpoint, resource does not exist.
- Example Response:
{ "error": "Not Found", "message": "Order with ID '12345' not found." }
405 Method Not Allowed: The request method is known by the server but is not supported by the target resource.
- Example Causes: Using POST on a resource that only supports GET.
- Example Response:
{ "error": "Method Not Allowed", "message": "POST method is not allowed for this endpoint." }
409 Conflict: The request could not be processed because of a conflict in the current state of the resource.
- Example Causes: Duplicate order submission, conflicting resource updates.
- Example Response:
{ "error": "Conflict", "message": "Order already exists with ID '12345'." }
422 Unprocessable Entity: The server understands the content type of the request entity, but the server was unable to process the contained instructions.
- Example Causes: Validation errors, semantic errors in the request.
- Example Response:
{ "error": "Unprocessable Entity", "message": "Invalid email address format." }
5xx Server Errors
500 Internal Server Error: The server encountered a situation it doesn't know how to handle.
- Example Causes: Unexpected server condition, unhandled exception.
- Example Response:
{ "error": "Internal Server Error", "message": "An unexpected error occurred. Please try again later." }
502 Bad Gateway: The server, while acting as a gateway or proxy, received an invalid response from the upstream server.
- Example Causes: Downstream service failure.
- Example Response:
{ "error": "Bad Gateway", "message": "Failed to connect to upstream service." }
503 Service Unavailable: The server is not ready to handle the request.
- Example Causes: Server maintenance, overload.
- Example Response:
{ "error": "Service Unavailable", "message": "The service is temporarily unavailable. Please try again later." }
504 Gateway Timeout: The server, while acting as a gateway or proxy, did not get a response in time from the upstream server.
- Example Causes: Upstream service timeout.
- Example Response:
{ "error": "Gateway Timeout", "message": "The request timed out while waiting for a response from the upstream server." }
Troubleshooting Tips
- Check Documentation: Refer to the API documentation for details on specific error codes and recommended actions.
- Validate Requests: Ensure your requests are properly formatted and include all required parameters.
- Handle Errors Gracefully: Implement robust error handling in your application to manage different error scenarios.
- Logging: Log errors for further analysis and troubleshooting.
- Retry Mechanism: Implement retry logic for transient errors like 5xx status codes.
Understanding these common error codes and their potential causes can help you quickly identify and resolve issues when working with an API OMS.