This entry is part of the Maximo Integration Framework series.
In this tutorial I will show how easy it is to query and update data in Maximo using the Integration Framework (MIF) REST interface.
To send REST calls you first need to setup an HTTP/REST client. In this tutorial I will use a Google Chrome add-on called Advanced REST Client.
Retrieve a record
In this first example I will show you to retrieve a PERSON record from Maximo using a REST call with an HTTP GET request:
Probably you will get an authentication error like this:
Error 401: BMXAA0021E - User name and password combination are not valid. Try again.
This means that you have to pass the authentication credentials to your request. If you are using native authentication you can pass the _lid and _lpwd arguments as described in this example:
Now you should see the PERSON record identified by the PERSONUID=1.
NOTE: For all the examples below I will exclude the authentication arguments for simplicity.
MBO and OS resources
The REST API provides access to business objects and integration object structures.
The two calls below will provide access to the same resource:
The first call access data straight from the PERSON object through MBO persistence layer.
The second call access data from the MXPERSON integration object structure through the MIF.
You will notice that results are slightly different.
Data format (XML or JSON)
By default Maximo retrieves data in XML format. JSON could be used instead passing the _format argument:
To retrieve the REVIS person record use the following REST call:
Note that Maximo will perform a wildcard search by default so if you type ‘re’ instead of ‘revis’ you will get a list of records that contains ‘re’ in the PERSONID field:
To search with an exact match use the ~eq~ token as demonstrated in this examples:
Results can be sorted using the _orderby, _orderbyasc or _orderbydesc argument. Multiple attributes can be passed separated by a comma character.
Create or Update a record (AddChange)
To create an existing record the AddChange action can be used. The following example will create a new person named RESTINT. Note that in this case a POST request must be used instead of a GET.
To update the same record we can use the PERSONUID returned from the create. In my example it’s 161.
Updating child objects
Lets now pretend we need to update an asset specification and one of its attributes. You will see things are now a little more complex.
First of all we can create a new asset with a POST request.
Take note of your ASSETUID and query the new record with a GET request.
Now login to Maximo, classify the MYASSET01 as a BEARING, add an ALN attribute and save it.
If you query the asset using the GET request above you will notice that you just have a CLASSSTRUCTUREID attribute with a number in it specifying the classification. This is not usable in our scenario and will not allow to update attribute.
The right approach is to switch to the object service structure. Try to query the new record with a GET request like this:
You will see that the HIERARCHYPATH field is now available and a subelement ASSETSPEC returns the attribute.
If we now want to update the value of the ALN attribute we can use a POST with a dotted notation like this:
If you want to set a new classification here’s an example:
Note how the spaces have been encoded in the URL with the ‘%20’ string. Hope this can help all of us dealing with integration scenarios using REST calls…