Error Handling
When using the openPIM API, you might encounter various errors. This section provides information on how errors are structured, common error codes, and examples of how to handle errors in your requests.
Error Structure
Our API responses for errors follow a consistent structure to help you easily understand and handle them. Below is an example of an error response format for both REST and GraphQL endpoints.
REST Error Example:
{
"errors": [
{
"statusCode": 429,
"name": "Error",
"origin": "authentication",
"rate_limit": {
"_remainingPoints": 400,
"_msBeforeNext": 400,
"_consumedPoints": 400,
"_isFirstInDuration": true
},
"date": "1970-01-01T00:00:00.000Z",
"message": "totalAppRateLimiter rate limit exceeded"
}
]
}
- errors: Can contain one or many errors.
- statusCode: The type of error.
- origin: Where the error comes from.
- rate_limit: Details for a rate limit error (can be NULL).
- date: Date error occurred.
- message: Explanation of the error.
GraphQL Error Example:
{
"errors": [
{
"message": "Argument 'GetProductsInput' has invalid value {product_ids: ['6647c18f1294fb312eb1cf9']}.",
"locations": [
{
"line": 2,
"column": 3
}
]
},
{
"statusCode": 429,
"name": "Error",
"origin": "unknown",
"rate_limit": {
"_remainingPoints": 0,
"_msBeforeNext": 400,
"_consumedPoints": 400,
"_isFirstInDuration": false
},
"date": "1970-01-01T00:00:00.000Z",
"message": "totalAppRateLimiter rate limit exceeded"
}
]
}
Note that there are two errors in this example. The first error is a standard GraphQL error indicating schema issues. The second error is a server error following a GraphQL error structure similar to the REST error structure, indicating rate limit or other server errors.
- errors: Can contain one or many errors.
- statusCode: The type of error.
- origin: Where the error comes from.
- rate_limit: Details for a rate limit error (can be NULL).
- date: Date error occurred.
- message: Explanation of the error.
- locations: Indicates where in the GraphQL query the error occurred.
Error Codes
Below are some common error codes you might encounter, along with their descriptions and suggested actions.
| statusCode | Description | Suggested Action |
|---|---|---|
| 400 | Bad request | Verify the input parameters and ensure they meet the API requirements. |
| 401 | Invalid Authorization Token | Check your Authorization token or generate a new one and try again. |
| 404 | Resource Not Found | Check the resource identifier and try again. |
| 429 | Rate Limit | Slow down your request rate and try again later. |
| 500 | Server Error | Retry the request later. If the issue persists, contact support. |