Common API Errors and Solutions
Last updated August 13, 2024
While Duffel's API is designed to be reliable, you may occasionally encounter errors during integration or use. This article will guide you through common API errors and their solutions.
Troubleshooting API Errors
- 400 Bad Request: This error typically indicates that your request is malformed or contains invalid data.
- Solution: Carefully review your API request, paying attention to:
- Data Types: Make sure that all data types are correct (e.g., strings should be enclosed in quotes, numbers should be in the correct format).
- Required Fields: Ensure you are providing all required fields in the request body.
- Parameter Values: Verify that parameter values are valid and within acceptable ranges.
- API Documentation: Consult the Duffel API documentation for specific details about request parameters, data formats, and validation rules.
- 401 Unauthorized: This error means your API request is not authenticated.
- Solution: Ensure you have set up your API credentials correctly and that your API key is included in the request headers. Verify that the key is valid and hasn't expired.
- 403 Forbidden: You're attempting to access a resource that you don't have permission for.
- Solution: Check the permissions associated with your API key. If you need access to a specific resource, you may need to contact Duffel support to request elevated permissions.
- 404 Not Found: The requested resource cannot be found.
- Solution: Verify that you are using the correct endpoint and that the resource you are requesting exists. Double-check the spelling and capitalization of your request URL.
- 500 Internal Server Error: This usually indicates a server-side issue with Duffel's API.
- Solution: If this error persists, contact Duffel support for assistance. They can investigate the issue and provide updates on any necessary fixes.
- Rate Limiting: If you exceed the allowed rate of API requests, you will receive a rate-limiting error.
- Solution: Review the Duffel API documentation for information on rate limits and strategies for avoiding them, such as using caching techniques.
- Timeout Errors: Your API request may time out if it takes too long to complete.
- Solution: Adjust your code to handle timeouts gracefully, and consider using strategies such as retries with exponential backoff to avoid repeated failures.
- Network Issues: Network connectivity issues might prevent successful API communication.
- Solution: Verify that your network connection is stable and that you have an active internet connection.
Remember, careful code review, adherence to the API documentation, and communication with Duffel support are key to resolving common API errors.
Was this article helpful?