Maximo Open Forum

 View Only
  • 1.  create a new worklog in an existing work order WO

    Posted 11-05-2021 16:22
    hi guys,


    im using the MAXIMO REST API to make some queries, using get and post operations.
    i wanna ask if somebody knows how to create a new worklog in an existing WO:

    im trying this:
    url_lref2='https://localhost/maximo/oslc/os/mxwo?lean=1&oslc.select=*&oslc.where=wonum="WO1943437"' --- > look for WO1943437

    r_ref3 = session.post(href_str,headers=myheaders,json=jedi)
    but im still getting 204 responde(no content)

    my headers are:
    myheaders = {
                 'maxauth': 'BASICHUNG2WQ==',
                 'x-method-override': 'PATCH',
                 'patchtype': 'MERGE',
                 'Content-Type': 'application/json',
                 'accept': "application/json"
                 }
    and the JSON body is:
    jedi={

       
        "worklog":

     
              {
                "modifyby": "USERNAME",
                "description_longdescription": "stextexetetxet<!-- RICH TEXT -->",
                "createdate": "2021-11-05T10:19:14-05:00",
                "description": "update",
                "orgid": "TEXHERE",
                "langcode": "ES",
                "_rowstamp": "268199803527",
                "createby": "USERNAME",
                "logtype": "CLIENTNOTE",
                "modifydate": "2021-11-05T10:19:54-05:00",
                "recordkey": "WO1943437",
                "siteid": "CCCN",
                "class": "WORKORDER",
                "logtype_description": "Client Note"
             
              }
                 

    }





    please any hint would be awesome.
    thanks for reading!






    #MaximoUserGroups

    ------------------------------
    alvaro molano
    kio
    ------------------------------


  • 2.  RE: create a new worklog in an existing work order WO

    Posted 11-10-2021 09:06

    MXWO out of the box doesn't include WORKLOG and I would not recommend modifying out of the box object structures. I would duplicate the object structure, add WORKLOG as a child object, and set the relationship to MODIFYWORKLOG (to avoid a GET request retrieving the entire worklog table).

    You shouldn't provide most of the attributes you listed when creating a WORKLOG. EX: recordkey, class, siteid, logtype_description, rowstamp, modifyby, modifydate, etc. as that will just increase your payload size and isn't needed to create a work log entry. 

    Are you making the GET request to get your HREF for that Work Order? IE after /mxwo do you have /_LONGSTRING? That string is the base 64 encoding of the primary keys of the object (so siteid & wonum in this case).

    I would make sure that you're making the request to the correct HREF, that the object structure is defined correctly, and simplify your payload to only the necessary fields and see what happens. 



    ------------------------------
    Steven Shull
    IBM
    ------------------------------



  • 3.  RE: create a new worklog in an existing work order WO

    Posted 11-11-2021 09:38
    Agreed with everything that @Steven Shull said.

    A sample URL might look like this:
    POST https://localhost/maximo/oslc/os/mxwo/Q0NDTi9XTzE5NDM0Mzc=?lean=1
    maxauth: BASICHUNG2WQ==
    x-method-override: PATCH
    patchtype: MERGE
    Content-Type: application/json

    A sample payload might look like this:
    {
      "worklog": [
        {
          "logtype": "CLIENTNOTE",
          "description": "update",
          "description_longdescription": "stextexetetxet<!-- RICH TEXT -->"
        }
      ]
    }

    Hope this helps,

    ------------------------------
    Alex Walter
    A3J Group, LLC
    ------------------------------



  • 4.  RE: create a new worklog in an existing work order WO

    Posted 11-11-2021 09:53
    alex thanks for taking the time to read and reply this, i really appreciatte your concern!
    one Q where did u get this url?  

    "https://localhost/maximo/oslc/os/mxwo/Q0NDTi9XTzE5NDM0Mzc=?lean=1"

    from href field from GET request?
    how did u request for that? any example?

    ------------------------------
    alvaro molano
    kio
    ------------------------------



  • 5.  RE: create a new worklog in an existing work order WO

    Posted 11-11-2021 10:07
    Normally, yes, the Q0N... portion of that URL can be retrieved by running something like this:
    GET https://localhost/maximo/oslc/os/mxwo?lean=1&oslc.select=wonum,siteid&oslc.where=wonum="WO1943437"
    maxauth: BASICHUNG2WQ==

    ... and getting the HREF value that comes back. In this case, I took the Site ID of CCCN and the WO Num of WO1943437 and combined them into a string CCCN/WO1943437 and Base64 encoded that string (this is essentially what Maximo does as Steven described).

    Remember to duplicate the MXWO object structure as Steven said before modifying it to include the WORKLOG object. That's a good practice as I've seen certain processes break by modifying out of the box object structures.

    Hope this helps,

    ------------------------------
    Alex Walter
    A3J Group, LLC
    ------------------------------



  • 6.  RE: create a new worklog in an existing work order WO

    Posted 11-11-2021 10:21
    thanks!
    how i can do this: "Remember to duplicate the MXWO object structure as Steven said before modifying it to include the WORKLOG object"
    im not the MAXIMO manager/admin, im just consumming the API from a python script, login into MAXIMO as a normal user with my credentials.

    does it can be done from code? if not, and it can be done only being the MAXIMO manager/admin i must quit this endeavour :(

    ------------------------------
    alvaro molano
    kio
    ------------------------------



  • 7.  RE: create a new worklog in an existing work order WO

    Posted 11-11-2021 09:56
    thanks for the reply i really appreciate it!


    any example for this?
    " I would duplicate the object structure, add WORKLOG as a child object, and set the relationship to MODIFYWORKLOG (to avoid a GET request retrieving the entire worklog table)."

    im pretty noobie to this, sorry for that

    ------------------------------
    alvaro molano
    kio
    ------------------------------