prieser
prieser

Reputation: 55

IBM Maximo REST service POST not setting attributes on MBO

I have tried to create a record of my customized object through REST service in IBM Maximo. The problem is that I created the record but I can't assign values to the attributes.

Next I will show what I did and what happened:

  1. I have an Object Structure called oxidato that represents my customized object.

  2. I did a POST using POSTMAN to this URL: http://hostname:port/maximo/oslc/os/oxidato?lean=1

  3. In the body section this is the JSON I was trying to send:

{
    "attribute1":"205",
    "attribute2":"206"
}
  1. The record was created but none of the attributes was filled.

In my opinion, the REST service received the POST but can´t read the body.

What am I missing? I add an image of the POSTMAN as example: enter image description here

enter image description here

EDIT1: I update the POST in order to use the newest API RES (Thanks Dex!)

EDIT2: I add an image of the header

Upvotes: 3

Views: 3181

Answers (2)

Dex
Dex

Reputation: 1271

I have found that Maximo will often ignore incoming attributes that aren't in the Maximo namespace (http://www.ibm.com/maximo). You could go through the trouble of setting up your VALOR1 and VALOR2 attributes to be in that namespace, but it's easier to just tell OSLC to ignore namespaces. You do that by setting the "lean" parameter to "1".

In your case, go to the "Params" tab and add an entry with a name of "lean". Give it a value of "1" and then send your POST again. You should see "?lean=1" appear at the end of the POST URL along the top there, but your body content should remain unchanged.

EDIT: On the other hand, it looks like (based on your URL) that you aren't actually using the newer JSON/OSLC REST API; It looks like you are using the older REST services. This IBM page gives you a lot of information on the newer JSON REST API, including the correct URLs for it: https://developer.ibm.com/static/site-id/155/maximodev/restguide/Maximo_Nextgen_REST_API.html. You should change your URL to /maximo/oslc/os/oxidato to use the newer API that naturally supports JSON and the lean parameter described above. This does required Maximo 7.6 to use though.

EDIT 2: The attributes are often oddly case sensitive, requiring lowercase. Your example in your question of "attribute1" and "attribute2" are properly lowercase, but your screenshot shows uppercase attribute names. Try changing them to "valor1" and "valor2". Also, these are persistent attributes, right?

Upvotes: 4

Maximo.Wiki
Maximo.Wiki

Reputation: 631

The response code received back (e.g. 200 - OK) and the response body will detail the record that was created.

I think you are correct in that the body of the post request is being ignored. Provided there are no required fields on the custom MBO your POST is probably creating an empty record with the next value in the sequence for the key field but you should see that in the response.

The following POST should create a record with values provided for attribute1 and attribute2 and provide a response with the record's identifier so that you can look it up in Maximo and show the values that were stored for attribute1 and attribute2:

http://hostname:port/maximo/rest/os/oxidato/?_format=json&_compact=1&attribute1=205&attribute2=206

Response: 200 OK 
Reponse Body: 
{   "CreateOXIDATOResponse": {
    "rsStart": 0,
    "rsCount": 1,
    "rsTotal": 1,
    "OXIDATOSet": {
      "OXIDATO": {
        "rowstamp": "[0 0 0 0 0 -43 127 13]",
        "ATTRIBUTE1": "205",
        "ATTRIBUTE2": "206",
        "OXIDATOID": 13
      }
    }   } }

You may also want to turn on debug logging for the REST interface in System Configuration -> Platform Configuration -> Logging for additional detail on what's happening in the log file.

Upvotes: 2

Related Questions