↓ Skip to main content
A pen and ink drawing of a post office counter with two identical envelopes side by side. The left one carries an orange round stamp mark, the right one lies under a teal paperweight. Behind them stand a brass receipt spike with a stack of slips, a rubber stamp on a teal ink pad and a brass hourglass.

Duplicate Requests, Timeouts and Retries in the Maximo REST API

The Maximo REST API in Practice - This article is part of a series.
Part 22: This Article
A client sends a create, and the connection drops before the answer arrives. Was the record saved? The client cannot tell, and a blind retry may save it twice. Manage has a header for exactly this case. This guide shows how to use it, and the traps we found on the way.

The rules here come from IBM’s documentation and from our own work with the REST API, on Manage in the MAS 9.2 series. We ran every request on our test system, as a user without administrator rights, on records made for the test and deleted afterwards.

A request without an answer can still be saved
#

We sent creates of service requests and aborted each one on the client a few milliseconds after it left. The client got no answer at all. When we sent the same requests again, Manage reported that each one had already been saved. The record existed, and the client did not know.

So a timeout, a reset connection or a crashed client never means “not saved”. A client that simply sends the request again creates a second record.

The header transactionid
#

A client gives each request an id of its own in the header transactionid. Manage stores the id with the record. When a request with the same id arrives again, Manage refuses it and points at the record the first request made.

POST /maximo/api/os/mxapisr?lean=1
apikey: <your key>
transactionid: 7c1e4d2a-5b0f-4c11-9a3e-2f6b8d90a1c4
content-type: application/json

{ "description": "Pump leaks at the seal" }
RequestAnswer
the first time201, Location names the new record
the same request with the same id409, BMXAA9524E, Location names the record of the first request

The 409 answer carries the usual error body:

{
  "Error": {
    "reasonCode": "BMXAA9524E",
    "message": "BMXAA9524E - The transaction ID 575 already exists …",
    "statusCode": "409"
  }
}

The full message reads:

BMXAA9524E - The transaction ID 575 already exists in the OSLC
transaction table with resource ID MXAPISR for object structure {3}.

The number in the message is the record’s internal id, here ticketuid 575. Your own id appears nowhere. Read reasonCode and the Location header, and leave the text alone.

Updates are checked too
#

An update through x-method-override: PATCH takes the same header. We sent one update with a new id and got 204. The same update with the same id answered 409, and the second change was not applied. A status change through action=wsmethod:changeStatus behaved the same way.

The retry rule
#

One id per intended change, sent again unchanged on every retry One id per intended change, sent again unchanged on every retry
One id per intended change, sent again unchanged on every retry

Four points make the rule work:

  • One id per intended change. Make it before the first attempt, store it with the request, and send it unchanged on every retry. A UUID fits.
  • 409 with BMXAA9524E is a success. The change is in Manage. Take the record from Location.
  • A changed request gets a new id. When the first attempt failed with a real error, the fix is a new request, and the old id would only be refused.
  • Reads need no id. A GET can always be sent again.

Three traps
#

The id is global. Manage compares the id alone, across every object structure. We sent a work order create with the id of an earlier service request. Manage answered 409, and Location named work order 7234-80, an old work order of the demo data. That work order has the same internal id as our service request, so the Location of a 409 on another structure points at an unrelated record. Never build the id from a record number or a counter that two clients can share.

The id of the create cannot carry the update. The update of a record with the id of its own create answered 409, and nothing changed. Each change needs its own id.

The id outlives the record. We created a service request with an id, deleted the record, and sent the create again. Manage answered 409. Location now named a record with empty keys, its rest id decodes to ~NULL~/~NULL~, and it answered 404. If records can be deleted between two attempts, a 409 with a Location that answers 404 means: the first request was saved, and someone removed the record since.

Which requests Manage checks
#

RequestChecked
POST to an object structure: createyes
POST with x-method-override: PATCH: updateyes
POST with an actionyes
HTTP DELETEno

A DELETE ignores the header: the second DELETE with the same id answered 404 with BMXAA8727E, the answer for a record that does not exist. That makes a delete safe to send again anyway, as the bulk article shows.

How long Manage remembers an id
#

IBM’s page says that Manage keeps an id for five minutes. The ids live in a table that the escalation OSLCTXNCLEANUP clears. On our system it runs every five minutes, and its action carries the parameter 5.

On our system an id was still refused more than ten minutes after its first use, when the escalation had run at least twice. So the five minutes are the schedule of the clean-up, and the id lives longer.

So do not build on a short lifetime. A client that reuses ids after a few minutes will be refused. Use a fresh UUID for every change, and ask your administrator to check the action of the escalation in the Actions application before you rely on any lifetime.

Timeouts
#

A long call passes several timeouts: the client’s own, a proxy or load balancer, and the route in front of Manage.

We measured the gateway of our test system with a test script that waits as long as the request asks. A call of two minutes came through. A call of five and a half minutes was cut at exactly five minutes:

504 Gateway Time-out
content-type: text/html

<html><body><h1>504 Gateway Time-out</h1>
The server didn't respond in time.
</body></html>

The 504 is an HTML page from the gateway, so a JSON client fails to parse it. And it says nothing about the work in Manage: a 504 is a timeout like any other, so the retry rule applies. Your gateway may cut at another limit; ask the team that runs it.

Three habits keep calls short and make timeouts rare:

  • Page through large reads instead of one huge call; see sorting and paging.
  • Send bulk requests in batches, so one slow item cannot hold the whole call.
  • Ask only for what you need. oslc.select and ignorecollectionref=1 make an answer smaller. On MXAPIWODETAIL, a page of work orders with ignorecollectionref=1 was almost a third smaller, because the links to its child lists were gone.

Set the client timeout above the longest normal call, and let the retry rule handle the rest.

What comes next
#

The next article collects field notes: answers that look fine and are still wrong.

IBM’s page is the reference to keep next to this article:

The series overview lists all parts. If you want help with the REST API in your own Manage, our services page shows how we work.

IBM and Maximo are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide.

The Maximo REST API in Practice - This article is part of a series.
Part 22: This Article