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
This entry is part [part not set] of 7 in the series Maximo REST API

Did You Know...

As Maximo Experts, we have developed several add-on products for Maximo that mobilize the work force, simplifies assignments, provides ad-hoc reporting capabilities and facilitates the seamless integration of Service Requests into Maximo.

Check out our products by clicking on the following links: EZMaxMobile, EZMaxPlanner and EZMaxRequest.

Find Out More

Leave a Reply