3

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

prieser
  • 55
  • 10
  • Try adding the "lean=1" parameter to your POST URL. I have found Maximo will often ignore attributes whose namespaces aren't configured to be in the Maximo namespace. The lean parameter basically strips namespace functionality. – Dex Jul 11 '20 at 03:13
  • Can you add a picture for what your POST headers are set up as, specifically your "properties" setting? Also, can you confirm with a database query that your data isn't there? – Dex Jul 15 '20 at 12:39
  • Yup! I confirmed with a query that the records are created but is not filling the attributes. – prieser Jul 15 '20 at 14:19
  • Thank you for that. Can you let me know the outcome of the second edit I made on my answer (lowercase attributes)? – Dex Jul 15 '20 at 14:31

2 Answers2

4

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?

Dex
  • 1,241
  • 6
  • 13
  • You are right Dex. I was using the old REST API just because I followed a old tutorial. Now I updated the URL, but the same keeps happening. I edited the original question with updated information. – prieser Jul 14 '20 at 22:00
2

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.

Maximo.Wiki
  • 631
  • 5
  • 17
  • Hi! I agree what you said. Its creating the record just using required fields. The POST you suggested is working correctly. Its filling all the fields fine. But I need to send in the body section. I dont know why is ignoring the body section. I think the Object Structure should be enough but maybe I forgot somethig. – prieser Jul 10 '20 at 22:02