↓ Skip to main content
A pen and ink drawing of the lever frame of an old railway signal box. A long row of iron levers with teal handles stands in a wooden frame, and one lever with an orange handle is pulled back. Below the frame, brass pulleys and wires run down into the floor, and a brass bell and an orange oil can stand on a shelf behind.

Actions, Workflows and Scripts in the Maximo REST API

The Maximo REST API in Practice - This article is part of a series.
Part 10: This Article
Some changes are no attribute update. A status change runs business rules, a workflow moves a record through a process, and a script does what you wrote. The REST API calls all of them the same way: a POST to the record with an action parameter. This article shows how to find, call and check them.

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, against IBM’s demo data, as a user without administrator rights. The examples act on service requests through the object structure MXAPISR, created for this article and deleted afterwards.

One parameter, four kinds of action
#

The prefix of the action parameter picks the kind of action The prefix of the action parameter picks the kind of action
The prefix of the action parameter picks the kind of action

The value of action has the form <type>:<name>. Without a type, Manage looks for an action defined on the object structure first, then for a system action.

Which actions a record offers
#

Add allowedactions to the select:

GET /maximo/api/os/mxapisr/<rest id>?lean=1
    &oslc.select=ticketid,allowedactions

The answer holds one entry per action, keyed by its full name. A service request offers dozens of them: web methods such as wsmethod:changeStatus and wsmethod:createWorkorder, and system actions such as candelete, duplicate and getlist. Each web method describes its own call:

"wsmethod:changeStatus": {
  "type": "wsmethod",
  "httpmethod": "POST",
  "impl": "changeStatus",
  "requestschema": {
    "type": "object",
    "properties": {
      "status": { "type": "string" },
      "memo": { "type": "string" },
      "date": { "type": "string", "subType": "dateTime" }
    }
  }
}

So a client does not have to guess the body. The schema names every parameter and its type.

Call a web method
#

A web method acts on the record of the URI. The POST needs x-method-override: PATCH, so Manage loads that record first:

POST /maximo/api/os/mxapisr/<rest id>?lean=1
     &action=wsmethod:changeStatus
x-method-override: PATCH
properties: status
{ "status": "QUEUED", "memo": "Sent to the help desk" }

With properties, the answer is 200 and holds the changed record, here "status": "QUEUED". Without it, the answer is 204. The parameters can also go into the query string: &action=wsmethod:changeStatus&status=PENDING with an empty body answered 204 and set the status.

Three mistakes and their answers:

RequestAnswer
the POST without x-method-override: PATCH500, a null pointer message
the same call as a GET400 BMXAA9484E, “The HTTP POST method must be used”
a method name that does not exist400 BMXAA9372E, “The action method nosuch was not found”

The first one is the trap: the message says nothing about the missing header.

The article on bulk requests uses changeStatus to cancel a work order, and shows a bulk request that calls it for many records at once.

System actions
#

Manage ships actions that work on any record. Four of them answer a GET:

ActionWhat it answers
candeletethe record when a delete is allowed, else the error a delete would give
duplicatea copy of the record with a new key (unsaved)
getlist~status on the record URIthe status values with their internal values
new on the collection URIa new record with its defaults (unsaved)

new and duplicate fill in a key, such as a new ticket number, and save nothing. We looked both records up afterwards, and both answered 404. A form can use them to show the defaults before the user saves.

Start a workflow
#

A workflow process starts with its name:

POST /maximo/api/os/mxapisr/<rest id>?lean=1
     &action=workflow:<PROCESS>
x-method-override: PATCH

There is a trap here. We started a process that does not exist, workflow:NOSUCHPROC. The answer was 204, the same as a success. A failed start looks exactly like a good one. So check the result yourself: the system action activewfinstances lists the active workflows of the record.

GET /maximo/api/os/mxapisr/<rest id>?lean=1
    &action=activewfinstances

After our failed start it answered an empty list, "member": []. A workflow start in an integration is not finished until this list shows the process.

Automation scripts as endpoints
#

A script can be an endpoint of its own, or an action on an object structure:

  • GET /maximo/api/script/<NAME> runs the script and returns what it writes to responseBody. A two-line test script answered our plain user like this:

    var site = request.getQueryParam("site");
    responseBody = JSON.stringify({ site: site,
      answer: "hello from a script" });

    GET /maximo/api/script/RESTDOC.HELLO?site=BEDFORD answered 200 with {"site":"BEDFORD","answer":"hello from a script"}. The script name in the URI is matched without case.

  • An action defined on the object structure runs a script with the record of the URI: POST <record URI>?action=MYACTION with x-method-override: PATCH.

Our series on automation scripts covers both in depth: your own REST API with a script and object structure actions and query scripts.

For members: the action catalogue
#

The member continuation lists what the short version leaves out:

  • the action catalogue of a record and of a collection, with allowedactions=1,
  • which web methods answer a GET, and how they return a value,
  • the service route, which calls a web method without a record,
  • statuslist, islocked and the other system actions that read state,
  • what each kind of action needs from the request.

🔒 The action catalogue of the Maximo REST API is members-only. To get access, get in touch.

What comes next
#

IBM’s own pages are the reference to keep next to this article:

The next part of the series watches IBM’s own clients: what the Manage UI and the MAF web apps send. 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 10: This Article