↓ Skip to main content
A pen and ink drawing of an open ledger on a wooden desk. A teal stencil with rectangular windows lies over the right page, so only a few ruled rows show through, and one window is outlined in orange. A second stencil with other windows, a magnifying glass and a pen lie beside the ledger.

Object Structure or Business Object: Two Ways to Read Maximo

The Maximo REST API in Practice - This article is part of a series.
Part 15: This Article
The REST API never reads a table. It reads an object structure, a view of one or more business objects that someone defined for integration. Most of the time that is invisible. When a column is missing or a delete fails on one structure and works on the next, the structure is the reason. This article shows what it changes.

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 REST API reads through a structure, a script reads the business object The REST API reads through a structure, a script reads the business object
The REST API reads through a structure, a script reads the business object

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,pluscpmextdate

The 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:

RequestAnswer
DELETE through MXAPIWODETAIL400 BMXAA0024E, “The action DELETE is not allowed on object WORKORDER”
DELETE through MXAPIWO204, 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
#

NeedPath
read and write records with IBM’s rulesobject structure
columns that no structure answersa structure of your own, or a script
a condition that OSLC cannot expressa saved query, or a script
one answer built from several objectsa 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 MXAPIWO and MXAPIWODETAIL, 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.

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