Sending an Asynchronous Request Using an Idempotency Key

The following is an example of a request that contains an idempotency key. The idempotency key enables you to refer to a request through a unique key, and also helps you avoid duplicate requests.

          POST /services/rest/record/v1/account
X-NetSuite-idempotency-key: cac827ea-3543-4cda-add2-bae634326c27
prefer: respond-async
{
  "name" : "My secret account"
} 

        

The following is an example of a response you receive after sending a duplicate request.

          HTTP 400 Conflict
Preference-Applied: respond-async
Location: /services/rest/async/v1/job/123456
Content-Type: application/json
{
    "type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.10",
    "title": "Conflict",
    "status": 400,
    "o:errorDetails": [
        {
            "detail": "A request with the same idempotency key is already submitted.             See the "Location" header for a link to the previously submitted job",
            "o:errorCode": "IDEMPOTENCY_ERROR"
        }
    ]
} 

        

Related Topics

General Notices