Retrieving and Posting data to Maximo REST Web Services

Maximo has always had web services that are available for use was limited to XML but now recently in Maximo 7.5, IBM has expanded it’s capabilities to work with JSON data.  What is JSON?  Just like XML, it is a universal human readable format that most applications can read.  JSON is short for Javscript Object Notation (Wiki).  If you are a programmer like myself, you probably like to work more with JSON than XML, or mabye that’s just me.

In this tutorial, I will walk you through retrieving data as well as sending data to Maximo REST web services.

I have previously written about REST webservices and given a high level overview of how it is setup and works, so if you aren’t familiar with that, you can read those here.

This post is about using SOAP UI to GET and POST data to these web services.

First thing is to download the latest version of SOAP UI.  This is a free tool that is used to test WSDL or REST web services.  Once download and installed, open and let’s create a new project.  Click File -> New REST Project,  A dialog will popup asking for the URI.  Enter this:

http://192.168.1.100/maxrest/rest/mbo/WORKORDER?_lid=maxadmin&_lpwd=maxadmin&_format=json

Replacing the IP address with your own maximo server and also the ‘maxadmin’ username and passwords.  Once done, click OK.

REST1

Retrieving Data

The project should open automatically with all your parameters.  You can see in the URL we have specified the WORKORDER mbo object.  You can change this to any object you’d like.  Assuming you have set the correct username and password, we can go ahead run it by clicking on the green play arrow button.  You will also notice the “method” is set to GET which means we will be retrieving data.

REST2

If your request is taking too long, it’s because we are trying to query ALL the WORKORDER records.  If so, you can stop it and we can limit the data we want.  In the request tab, we can add a new parameter by clicking the plus sign and adding a new parameter called “_maxItems” and set the value to 1.  Now run the request again.  This time it should return the first record in the set.  To view the JSON data, click the JSON tab on the right window.

REST3

So now you can get data from Maximo with the JSON format.  But what about adding queries to your request to get only certain records?  Well, you can add more parameters to filter the data set.  So let’s find work orders that have a work type equal to ‘CM’ and a priority less than or equal to 1.

Click the plus button to add a new query parameter and let’s add the field properties of the WORKORDER object such as WORKTYPE and WOPRIORITY.  Set the worktype equal to ‘CM’ and the priority to ‘~lteq~ 1’.  You cannot use the ‘<=’ sign here because those are not ‘safe’ characters so IBM docs states that you have to use this format instead.

REST4

Now click run and you should see the returned results.

Posting Data

Next goal is to post data to the web service such as creating a new work order in the system. In the navigation window, right click on WORKORDER and select ‘New Request’

REST5

In the dialog, enter the same web service URL we used previously.

http://192.168.1.100/maxrest/rest/mbo/WORKORDER?_lid=maxadmin&_lpwd=maxadmin&_format=json

Now we want to change the web service method to POST

When you do this, a window will slide open where you can enter the data you want to post to the web service.

Now before we enter anything, let’s understand what Maximo is expecting.  People assume that because the REST web service can return JSON data, they also assume that you can post JSON data.  This is incorrect.  If you try to post any data in a format that the web service doesn’t recognize, you will simply get an exception and scratch your head wondering why it doesn’t work (believe me, I did).

Back to Soap UI, in the ‘Media Type’ window, you can try for yourself.  If you post JSON data like so:

{
      "SITEID" : "BEDFORD",
      "DESCRIPTION" : "Test REST services"
}

You will get an exception stating, ‘Error 400: BMXAA4153E – null is not a valid site’;  This is because the web service doesn’t know to parse the message body of the request for SITEID in the JSON object.  So how do we post data if not in JSON format?  The answer is query string parameters in the message body.

First we must check the box ‘Post QueryString Parameters’, then we can add any properties we want to the request.  So let’s say we want to create a new work order with a description of ‘Test REST services’ and a worktype equal to ‘CM’, this is what we add:

REST6

Now run it, and you should get a response.  The JSON response should be the one work order record you created with the description you specified.

Series Navigation< Create a work order and add labor hours with Maximo RESTAdd Work Log to SR through Maximo REST API >

Did You Know...

As Maximo Experts, we have developed Maximo adds on products to make Maximo work assignment simple, reporting easy, and facilitating service requests seamless. Check out our additional products EZPlanner, EZInsight, and EZRequest.

Find Out More

9 thoughts on “Retrieving and Posting data to Maximo REST Web Services

  1. The REST api calls into MAXIMO cannot actually use payloads, can they? All the data has to be part of the request URL as parameters? You can’t have it process an XML or JSON payload file? That is how I see it work, just wanted to confirm

      1. Hi, I know the standard MIF does accept XML payload. What I am asking is the REST api call to create a person record for example.

        http://HOSTNAME:PORT/maxrest/rest/os/mxperson?_action=AddChange&ACCEPTINGWFMAIL=1&ADDRESSLINE1=TestStreet&DISPLAYNAME=RESTINT&FIRSTNAME=REST&LASTNAME=INT&amp;

        LOCTOSERVREQ=1&PERSONID=RESTINT&SENDERSYSID=MX&STATUS=ACTIVE&TRANSEMAILELECTION=NEVER&WFMAILELECTION=PROCESS
        As you can see here, the entire information is one URL. It can’t be a payload XML file as far as I can see. Just checking if that is possible

          1. Do you have an example by any chance please? In your article above too, you do say if you just put a json string as the body, it fails with 400 error code, because maximo does not know how to parse it. In my case, if I try the RESTClient, with the URL http://server:9080/maxrest/rest/os/mxperson, and the actual values in the body as XML / JSON, it does not work. Fails with 400 bad request as Personid requires a value. In your example you use query string parameters, which internally does translate into parameters in the URL itself, if I understand it right.

          2. Thank you. That does work when we are using a user facing POST source like an HTTP form. If a system is to call Maixmo though, like a monitoring solution calling to create an SR in Maximo automatically on an event, I think it will still have to use the existing non-REST MIF methods if it wants to send the data as a file. It can use REST only if it can pass all the required values as parameters in the POST url itself? I can’t tell them, you make a POST to http://server:9080/maxrest/rest/os/mxincident, and pass the values as a payload file

Leave a Reply

Your email address will not be published. Required fields are marked *