The rules here come from IBM’s documentation and from our own work with the REST API and with automation scripts, on Manage in the MAS 9.2 series. We ran every request on our test system, as a user without administrator rights, on IBM’s demo data and on records made for the test.
Two paths to the same record#
The path /os/ is the REST API as this series knows it. There is no path that reads a business
object without a structure: we tried /maximo/api/mbo/asset, and every such call answered 500. The
second path is a script. It runs on the route /script/, opens the business object itself, and
returns what it chooses.
The structure picks the columns#
MXAPIASSET is IBM’s structure for assets. We asked it for five attributes:
GET /maximo/api/os/mxapiasset?lean=1
&oslc.where=assetnum="11300"
&oslc.select=assetnum,status,iscalibration,
pluscismte,pluscpmextdateThe answer held assetnum, status and pluscpmextdate. iscalibration and pluscismte were
missing, without an error. They are columns of the asset, and the structure’s own JSON schema even
lists them, but MXAPIASSET never answers them. A client that checks each selected name finds the
gap; a client that does not check reads null and moves on.
A small script on the business object read the same asset:
var MXServer = Java.type("psdi.server.MXServer");
var set = MXServer.getMXServer()
.getMboSet("ASSET", request.getUserInfo());
set.setWhere("assetnum = '11300' and siteid = 'BEDFORD'");
var a = set.moveFirst();
responseBody = JSON.stringify({
assetnum: a.getString("ASSETNUM"),
iscalibration: a.getBoolean("ISCALIBRATION"),
meters: a.getMboSet("ASSETMETER").count() });
set.close();It answered with iscalibration and the meter count. The script runs as the calling user, through
request.getUserInfo(), so the user’s rights still apply. Our
script series shows how to build such
an endpoint safely.
The structure picks the children#
A child list in a structure is a relationship that the structure names. MXAPIASSET reads the
meters of an asset through the relationship INT_ASSETMETER. The asset also has the relationship
ASSETMETER, which our script used. The link in every record shows the structure’s choice:
"assetmeter_collectionref": ".../mxapiasset/<rest id>/int_assetmeter"Two relationships can hold different rows. When the meters in the API differ from the meters on the screen, compare the two relationships first.
The structure picks the rules#
The same record behaves differently through two structures. IBM ships MXAPIWO and
MXAPIWODETAIL, both on work orders. We read work order 1000 through each: MXAPIWO answered 110
attributes and one child list, MXAPIWODETAIL 117 attributes and 22 child lists. Then we created a new work order and deleted it:
| Request | Answer |
|---|---|
DELETE through MXAPIWODETAIL | 400 BMXAA0024E, “The action DELETE is not allowed on object WORKORDER” |
DELETE through MXAPIWO | 204, deleted |
The record and the user were the same. The structure decides which actions it allows. So when a write fails, try the request on a second structure for the same object before you change the data. The article on bulk requests shows how a work order is cancelled when it must stay.
The where clause is OSLC#
oslc.where takes the syntax of the first article. SQL
does not get through: oslc.where=assetnum='11300' answered 400 with BMXAA8744E, “The OSLC query was
not parsed”. A script sets SQL with setWhere, so a condition that OSLC cannot express belongs in a
script. That condition then sits in your script, and you guard its input yourself.
Which path to choose#
| Need | Path |
|---|---|
| read and write records with IBM’s rules | object structure |
| columns that no structure answers | a structure of your own, or a script |
| a condition that OSLC cannot express | a saved query, or a script |
| one answer built from several objects | a script |
The structure is the default. It brings paging, selection, properties, bulk and every feature of
this series. A script is the exception for the one thing a structure cannot do.
For members: the measurements in full#
The member continuation lists every difference we measured between the two paths:
- how to find the columns a structure never answers, for any structure,
- the full comparison of
MXAPIWOandMXAPIWODETAIL, child list by child list, - a script endpoint that checks its input before it touches the database.
🔒 What an object structure changes, measured is members-only. To get access, get in touch.
What comes next#
The next article explains API keys, tokens and the two
routes /maximo/api and /maximo/oslc.
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.
