MAS 9.2 series companion app REST API
The app is our skeleton on our test system, on the MAS 9.2 series. Reaching Manage From Inside the Cluster puts this way beside the other one.
The module#
/**
* REST calls to Maximo Manage as the signed-in user.
*
* The access token of the session goes to Manage in the header x-access-token, on the
* route /oslc. Manage answers with what this user may read, so the app needs no
* permission logic of its own for data.
*/
import { config } from "../config.js";
export async function manageGet(accessToken: string, path: string, params: Record<string, string> = {}): Promise<{ status: number; body: any }> {
if (!config.manageUrl) throw new Error("MANAGE_URL is not set");
const query = new URLSearchParams({ lean: "1", ...params });
const response = await fetch(`${config.manageUrl}/oslc/${path}?${query}`, {
headers: { Accept: "application/json", "x-access-token": accessToken },
// Without a valid token Manage answers 302 to the sign-in. The caller gets that status.
redirect: "manual",
});
const text = await response.text();
let body: any = text;
try {
body = JSON.parse(text);
} catch {
// Manage answered with something that is no JSON; hand the text on.
}
return { status: response.status, body };
}Four things in it are worth a look:
- The token goes into the header
x-access-token. It is the access token from the sign-in, taken from the session of the app. - The route is
/oslc. That is the route of the REST API behind the sign-in of the suite, as API Keys, Tokens and the Two Routes of the Maximo REST API describes. - The address is a setting,
MANAGE_URL. Our deploy script sets it to the service of Maximo Manage inside the cluster. - A redirect goes back to the caller. The setting
redirect: "manual"is there for a caller with no valid token, as the section on the three callers shows.
One request for ten work orders#
/** Ten work orders, read from Manage's REST API as the signed-in user. */
apiRouter.get("/workorders", async (req, res) => {
const token = (req.session as any)["x-access-token"] ?? (req.user as any)?.accessToken;
if (!token) return res.status(401).json({ error: "no session" });
try {
const { status, body } = await manageGet(token, "os/mxapiwodetail", {
"oslc.select": "wonum,description,status,siteid",
"oslc.where": 'status="APPR"',
"oslc.orderBy": "-wonum",
"oslc.pageSize": "10",
collectioncount: "1",
});
if (status !== 200) return res.status(502).json({ error: "Manage answered " + status, detail: body?.Error?.message ?? String(body).slice(0, 200) });
res.json({
total: body?.responseInfo?.totalCount ?? null,
workorders: (body?.member ?? []).map((w: any) => ({ wonum: w.wonum, description: w.description, status: w.status, siteid: w.siteid })),
});
} catch (err) {
res.status(502).json({ error: "Manage unreachable", detail: err instanceof Error ? err.message : String(err) });
}
});The request asks the object structure mxapiwodetail for four attributes of the approved work orders, highest number first, ten per page, with the total count. The route hands a small answer on to the page: the total, and four fields per work order.

Signed in as an administrator, the page showed “10 of 1135”. The answer of the route to the browser was 674 bytes, after 172 ms. Signed in as a planner, with the gate of the app set to an option the planner holds, the same request gave “10 of 354”.
The app has no rule about who sees which work order. Maximo Manage decided, from the token.
The parameters are the ones of the REST API. Our series on it has a page for each: the select clause, the where clause, sorting and paging, and counts.
What Maximo Manage answered to three callers#
We asked the same address from inside the pod three ways:
| The request carries | Answer |
|---|---|
| the token of the signed-in user | 200, with the data |
| no token | 302 to the sign-in of the suite |
| a made-up token | 302 to the sign-in of the suite |
A caller with no valid token gets a redirect to the sign-in. Our module hands that redirect back to the route: with a made-up token it returned the status 302 after 34 ms. The route treats every status other than 200 as a failure and answers 502 to the page.
Our first version followed the redirect. fetch follows a redirect unless it is told otherwise. The sign-in is at a public address of the suite, and a call from the pod to that address failed. With a made-up token, the call then ended in the error “self signed certificate in certificate chain”. In the route that error lands in the catch, which reports “Manage unreachable”. That text sends a reader to the wrong place. With redirect: "manual" the route reports “Manage answered 302”.
The address matters#
A request from the pod to the public address of Maximo Manage failed with “self signed certificate in certificate chain”. Our first deploy script used that address, and we changed it to the service address inside the cluster.
The service address inside the cluster worked. The pod trusts it through the certificate authority in its mounted secret. Our deploy script sets MANAGE_URL to that address, with its path.
What we take from it#
- Send the user’s token, in
x-access-token, on/oslc. Maximo Manage then answers as it would answer this user. - Ask only for the attributes the page shows. The route’s answer to the page, four fields for ten work orders, came to 674 bytes.
- Hand a redirect back to the caller. Without a valid token, Maximo Manage answered 302, and a followed redirect ended at an address the pod did not trust.
- Call Maximo Manage at its service inside the cluster. The public address was not trusted from our pod.
What to read next#
The User Interface: Carbon Without @maximo is about the page that shows this data. The series The Maximo REST API in Practice has the API itself. Authorization: Reusing Maximo’s Signature Options shows the gate in front of this route.
