by | Jun 22, 2022

    Developing Custom Mobile App using Maximo REST API

    The mobile app for Maximo operations is a gateway to IoT and Advanced Analytics by capturing precise data at the point of performance and data not being captured when using the desktop version of Maximo. As assets become smarter and existing businesses need more efficiency, it is natural to lean on mobile platforms for better asset management.

    The new REST APIs for IBM® Maximo® Asset Management are a rewrite of the existing REST APIs that were released after Maximo Asset Management version 7.1, and are integrated into Maximo Asset Management releases starting with version 7.6.0.2. The new REST APIs are sometimes referred to as the REST/JSON APIs because of the end-to-end support for JSON data format.

    Maximo REST API makes it easier for software developers, especially mobile application developers. The back-end system from Maximo is sufficient to meet the needs of making mobile applications. Of course, not only mobile apps but desktop apps and website apps can also be developed, but this time we will focus on mobile development.

    For more details on the API, refer to the documentation here.

    1. Prepare REST API Library.


    Before starting the development of the Mobile App, the developers may need to configure their API Library and can do the integration test through it. Several applications can be utilized for this like Postman, Swagger, REST Client VSCODE, etc. For the current topic we will setup for:

    a. Get API key

    Request Configuration :

    host: https://host/maximo/oslc/

    maxadmin : base64encode(username:password)

    Developing Custom Mobile App using Maximo REST API

    Positive result:

    Developing Custom Mobile App using Maximo REST API

    If the login is successful, it will have a response body for the API key. API keys are created for a given Maximo user and the API calls made using that API key effectively works in the context of the said user. This implies all the user’s permissions are respected in that API call. REST APIs invoked using API keys use “silent” login. This implies that there are no MAXSESSION entries created. By default, there would not be any server-side web sessions. This implies that clients using REST APIs with API keys, do not need to call the /logout API as there is no persistent server-side session. API keys can be created and revoked as needed. There is only one API key per user allowed at this point. Each of these API keys may have an expiry (in minutes). The expiry time is specified at the time of creation. An expiry time of -1 implies the key will never expire. The only way to invalidate the key would be to revoke it manually. Below we list the REST APIs that can be used to create/revoke the API keys.

    Negative Result:

    Developing Custom Mobile App using Maximo REST API

    A negative response will be handled by Maximo, the developers only need to capture what message is causing the login to fail.

    b. Revoke API key

    Request Configuration :

    Developing Custom Mobile App using Maximo REST API

    Positive result:
    Response Status Code: 200

    If the response status code from the request is 200 that means the API key is revoked and can no longer be used to make further API requests.

    c. Profile

    Request configuration:

    Developing Custom Mobile App using Maximo REST API

    As you can see, now we use API key header and the value is coming from the previous request. The benefit of using this API key is that we don’t disclose the username and password of the Maximo user, instead of that we just share a token that cannot be decrypted and it can be expired within the time that we setup during the API key creation.

    Result

    Developing Custom Mobile App using Maximo REST API

     

    Developing Custom Mobile App using Maximo REST API

    Whoami is an out-of-the-box REST API function from Maximo, and the purpose of that is to get the detailed data of current user login whether it using maxauth or apikey.

    d. Result Set 

    The REST APIs have tight integration with the automation scripts. Automation scripts can be used to develop custom APIs. The following example call describes how automation scripts interact with REST APIs. To find the total number of work that is in progress and service requests on a given site, you need to create an API since there is no out-of-the-box API for this task. Since this is a REST API with a JSON response, you can use the JavaScript language for scripting. You call this API countofwoandsr.

    Automation Script

    Script name: countofwoandsr

    Language: Javascript

    Developing Custom Mobile App using Maximo REST API

    Request configuration

    Developing Custom Mobile App using Maximo REST API

    Here you can specify the site id on the parameter, or you can adjust any parameters based on your code requirement.

    Result

    Developing Custom Mobile App using Maximo REST API

    e. Workorder List

    Object structure

    For workorder data in Maximo REST API you need to prepare the object structure, Go To Integration > Object Structure.
    Create New Object Structure, and choose the parent object as WORKORDER.

    Developing Custom Mobile App using Maximo REST API

    Request configuration

    Developing Custom Mobile App using Maximo REST API

    From the request we can use select, where or limit the number of records that need to be fetched.

    Result

    Developing Custom Mobile App using Maximo REST APIDeveloping Custom Mobile App using Maximo REST API

    Voila! We’ve successfully set up and tested the REST API Library which we will use for our mobile development. Next, let’s jump into the main part!.

     

    2. Flutter Cross Platform.


    Flutter is an open-source framework by Google for building beautiful, natively compiled, multi-platform applications from a single codebase. On this topic, we will be using flutter for Mobile framework development.

    a. Login and Profile

    Developing Custom Mobile App using Maximo REST API

    Developing Custom Mobile App using Maximo REST API

    In Flutter we can configure one function to call two requests sequentially. Under this login function first, we call the request to get the apikey value and check if the API key generation is successfully made.  If yes, then pass the apikey value for the next request for calling the whoami REST API function.

    b. Logout

    Developing Custom Mobile App using Maximo REST API

    Developing Custom Mobile App using Maximo REST API

    This request is to revoke the API key by calling the apitoken/revoke, and after that, we check the response status code.

    c. Result Set

    Developing Custom Mobile App using Maximo REST API

    This function will be used to get the number of workorder based on status and status date. In this function, we call getToken first to retrieve the apikey value. If the value exists then we can continue the request if not then it will throw a message error and redirect to the login page.

    d. Workorder List

    Developing Custom Mobile App using Maximo REST API

    This function is for getting the detailed workorder data and it will be fetched under the workorder list of the mobile app.

    3. Mobile App

    a. Login

    Developing Custom Mobile App using Maximo REST API

    In this figure, we can see the login user interface, and it requires a username and password. Here we can also set the configuration like the hostname and port if we want to easily move between the Maximo environment. From the login button, the request for calling the API key request and then whoami request will be made. And if successful, it will redirect to the Dashboard page of the mobile app.

    b. Dashboard

    Developing Custom Mobile App using Maximo REST API

    Developing Custom Mobile App using Maximo REST API

    In this figure, we can see the dashboard of the mobile app after the user successfully enter the correct username and password the user will be directed from login to the dashboard page. From this page we can see the result set of workorder data, this result set also can be filtered by clicking the date range button and selecting the date of workorder that you want to fetch.

    c. Workorder

    Developing Custom Mobile App using Maximo REST API

    Developing Custom Mobile App using Maximo REST API

    In this figure, we can see the workorder page by clicking the paper icon under the bottom tab. And by clicking the refresh button it will call the workorder API request and if it is successful, it will retrieve the workorder data under this card list.

    d. Profile and logout

    Developing Custom Mobile App using Maximo REST API

    In this figure, we can see the profile of the user who login into the mobile app. Here only the display name, organization and site will be retrieved for the user information. For the current session Update Profile and Change Password are not developed yet, but of course, for the logout button, it will work since we have prepared the function to call the revocation of the spiky, if the logout button is clicked and it will redirect the user to the login page.

    In this session we only discuss simple mobile applications, there are many more that can be explored and developed depending on the requirements needed. This is just to open our eyes, especially for all mobile developers to think about this because now and near future there will be a lot of needs for the EAM App in the mobile version which is of course more customized.

    Don’t forget to share it and hope this little information can be useful for all who read it.  If you need further help with Maximo or Mobile Solutions, please don’t hesitate to contact us here.

     

    Sign up to our free newsletter to explore emerging technologies, industry events and Maximo best practice.