Creating New API Routes
Maximo REST APIs Maximo supports creating entirely new routes using API routes. Every existing Maximo API’s are based on OOTB API Routes.
To create an new API, we can either approach it using automation scripting or by leveraging Java.
For automation scripting approach please refer to the automation scripting guide https://ibm-maximo-dev.github.io/maximo-autoscript-documentation/rest/scripthandler.
For the Java approach, one needs to extend the base class com.ibm.tivoli.maximo.oslc.provider.AbstractRouteHandler and implement the method
public OslcResourceResponse handleRequest(OslcRequest request) throws MXException, RemoteException
The request
param encapsulates the REST call and provides information like UserInfo, HTTP headers, query parameters etc. A sample implementation is shown below
package com.ibm.tivoli.maximo.oslc.provider;public class SampleRouteHandler extends AbstractRouteHandler {@Overridepublic OslcResourceResponse handleRequest(OslcRequest request)throws MXException, RemoteException{if(this.resPath.size()==1){
Note that to register the route one needs to go to Object Structure Appplication - (Action) API Routes dialog. In that dialog provide a route name and the class name or the script name (script:<Script Name>
) and save.
Optionally one can enter the security application and the sigoption to secure the routein case the route implementation does not provide native security.
One such example would be Object Structures, which provide authorization natively using Object Structure Security. In that case, we do not need to provide security at the route level.
The route cache should get refreshed and the route should be live after a successful save.