Errors & Retries

The HTTP statuses GAINS Connect returns, the shape of each error body, which errors to retry, and which Idempotency-Key to resend with.

GAINS Connect reports every outcome with a standard HTTP status and, for errors, a JSON body that says what went wrong. Use this page to read an error response, to decide whether to fix the request or retry it, and to choose the Idempotency-Key for a resend.

Read an error response

Most errors return a single Reason:

{
  "Reason": "The field 'ItemCod' is not recognized. Please ensure you are using the correct field names and try again."
}

Some responses carry a different body:

WhenBody
Several fields fail validation at onceReasons, an array of messages, instead of Reason.
An unexpected server error (500)error_id and Reason. Quote the error_id to support. Some 500 responses carry only a Reason.
An endpoint needs a newer GAINS X version (426)The installed and required GAINS X versions.
A submit rejects some or all records (207, 422)The rejected records and why. See Rejected Records.
{
  "Reasons": [
    "Gap must be at least 1 minute",
    "PayloadMaxItems must be greater than 0"
  ]
}
{
  "error_id": "3f0b7c52-9a1e-4d6b-8e2f-5c4a1b7d9e03",
  "Reason": "We encountered an unexpected issue. Please report this to [email protected] and reference error ID 3f0b7c52-9a1e-4d6b-8e2f-5c4a1b7d9e03"
}

Branch on the status code, not on the text of Reason. The text explains the problem to a person and can change between releases.

Status codes

StatusMeaning
200 OKThe request succeeded.
202 AcceptedA submit passed validation and was queued as a task. Follow it with GET /tasks/{TaskId}.
204 No ContentNothing to return, for example no webhook settings yet.
207 Multi-StatusA submit was partly accepted: the valid records were queued, the rejected ones are listed.
400 Bad RequestThe request is malformed, for example invalid JSON, an unknown field or a value of the wrong type, or it repeats an Idempotency-Key.
401 UnauthorizedCredentials are missing, expired or invalid, GAINS refused the Basic user name or password, or a partner endpoint received Basic credentials. See Authentication.
403 ForbiddenYour credentials are valid but not for this endpoint, or the service is not part of your environment.
404 Not FoundThe path does not exist, or it names something that does not exist, such as a webhook.
405 Method Not AllowedThe endpoint does not accept this HTTP method.
415 Unsupported Media TypeContent-Type is missing or is not application/json.
422 Unprocessable ContentA submit accepted no records: every record failed validation, the array was empty, or it held more records than a submit accepts.
424 Failed DependencyA custom route is configured but not ready yet. Retry later.
426 Upgrade RequiredThe endpoint needs a newer GAINS X than your environment runs; see When your version is too old (426).
429 Too Many RequestsGAINS Connect is still taking in earlier submits and did not accept this one. Retry after Retry-After; see Load Throughput & Retries.
500 Internal Server ErrorAn unexpected error. Report the error_id when the body carries one.
503 Service UnavailableGAINS cannot be reached, is in its daily maintenance window, returned an error, or loads are not enabled for your environment, or the authentication service is unavailable during a Basic login; see GAINS Versions & Availability.
504 Gateway TimeoutGAINS did not answer in time; see GAINS cannot be reached.

The API Reference lists, for each endpoint, the statuses it documents.

Decide whether to retry

Match the status code first. For a 403 or a 503, also match the Reason: different ones need different actions.

ResponseRetry?
No response, or the connection droppedYes, after a delay.
400 The idempotency key indicates a duplicate payload.Not yet: the first request may have been accepted. See Idempotency.
Any other 400, and 404, 405, 415, 422No. Fix the request first.
401After you correct the credentials or request a new token.
403No. Request a token with access to this route, or contact your GAINS representative if the service is not part of your environment.
424Yes, later. The custom route is not ready yet; see Custom Schema.
426No. Upgrade GAINS X; see When your version is too old.
429Yes, the same request, after the Retry-After interval; see Load Throughput & Retries.
500Once, after a delay. If it fails again, report the error_id.
503 daily maintenanceYes, every few minutes until the window ends. Submits are not affected.
503 GAINS cannot be reached, or GainsX returned an internal errorYes, after a delay.
503 Authentication service is currently unavailable.Yes, after a delay.
503 This feature is not configured for your environment.No. Ask your GAINS representative to enable loads.
Any other 503No. Contact your GAINS representative.
504Yes, after a delay.

How long to wait between attempts, and when to stop, is in Load Throughput & Retries.

Which key to resend with

When you resend a submit, the Idempotency-Key depends on what the first attempt received:

First attempt receivedResend with
429, or no response at allThe same key. After a 429 nothing was saved and the key was released; with no response you cannot tell whether the first request was accepted, and the same key stops it being loaded twice.
Any other error responseA new key. Nothing from the request was saved, and the key may already be recorded, so resending under it would be refused as a duplicate.
400 The idempotency key indicates a duplicate payload.Nothing yet. Check whether the first attempt was accepted, as Idempotency describes.

Once you change the records, always use a new key. How keys work is in Idempotency.

Related


Did this page help you?