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"
        }
    ]
}

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.


Error Codes

Below are some common error codes you might encounter, along with their descriptions and suggested actions.

statusCodeDescriptionSuggested Action
400Bad requestVerify the input parameters and ensure they meet the API requirements.
401Invalid Authorization TokenCheck your Authorization token or generate a new one and try again.
404Resource Not FoundCheck the resource identifier and try again.
429Rate LimitSlow down your request rate and try again later.
500Server ErrorRetry the request later. If the issue persists, contact support.

Next we will cover: