Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
Expand all | Collapse all

Is it possible to create a communication log entry via rest api?

  • 1.  Is it possible to create a communication log entry via rest api?

    Posted Wed March 29, 2023 03:26 PM

    I would like to create communication log entries for service requests via rest api. Is this possible? Any examples on what needs to be passed for data/syntax?



    ------------------------------
    Christopher Stewart
    ------------------------------

    #MaximoIntegrationandScripting
    #Maximo


  • 2.  RE: Is it possible to create a communication log entry via rest api?

    Posted Thu March 30, 2023 09:09 AM

    Are you looking to store it or actually send the email. Assuming you want to send the email, I documented this as a REST API action automation script here: https://ibm-maximo-dev.github.io/maximo-autoscript-documentation/rest/osaction

    If you wanted to store the data (but not trigger an email) you should be able to add commlog as a child object and provide that on the POST request. 



    ------------------------------
    Steven Shull
    ------------------------------



  • 3.  RE: Is it possible to create a communication log entry via rest api?

    Posted Thu March 30, 2023 10:29 AM

    I am just looking to store a communication log, not send one. Our IT department will not allow the Maximo email listener to be set up to store communication replies from emails. I would like to use MS power automate to do that same thing. When a new email arrives from Maximo, make a post request and update the necessary service request with the data from the email.

    I am attempting to do something like the following. What would the URL be to create a new commlog? 

     



    ------------------------------
    Christopher Stewart
    ------------------------------



  • 4.  RE: Is it possible to create a communication log entry via rest api?

    Posted Fri March 31, 2023 08:21 AM

    You can use Maximo NextGen Rest APIs through
    For detail information, you can refer to my blog https://jackyqiubao.medium.com/introduction-of-maximo-nextgen-rest-apis-part-2-update-maximo-data-e3db83751709



    ------------------------------
    Jacky Qiu
    Technical EAM Director
    Stellar Services
    Atlanta, GA
    ------------------------------



  • 5.  RE: Is it possible to create a communication log entry via rest api?

    Posted Fri March 31, 2023 08:57 AM

    First step is we need to create a new object structure in Maximo. MXAPISR is an out of the box object structure that doesn't have COMMLOG as part of it so we can't send the data we need for it to process.

    In the Object Structures application of Maximo:
    1) Duplicate MXAPISR. We want to duplicate out of box object structures when possible. I used the name EMXAPISR. You can use whatever you want, but I would recommend coming up with a prefix that you use consistently throughout Maximo to indicate that it's something your company has configured.
    2) Delete the child objects you won't be using. Most of these (like SITE) were used for retrieval of information and should have never been part of the object structure anyways. I deleted all of them because I just plan to send COMMLOG
    3) Add COMMLOG as a new object. Parent Object is SR and relationship is COMMLOG


    Once you save that we're ready to try and make the request.

    Method of PATCH is logical but you actually need it to be a POST with some headers to indicate that it's an update. I'll provide you values as a starting point and then go into some details below that.

    URI: https://site.com/maximo/api/os/emxapisr?lean=1
    Method: POST
    headers:
    x-method-override: SYNC
    patchtype: MERGE
    apikey: YOURAPIKEY
    body:

    {
        "ticketid":"1001",
        "class":"SR",
        "commlog":[
            {
                "sendfrom":"myemail@company.com",
                "createby":"MAXADMIN",
                "subject":"This is your email subject",
                "message":"This is your email body",
                "inbound":true
            }
        ]
    }

    The lean=1 allows us to avoid some OSLC concept such as namespaces (the spi: prefix) and reduces the size of the JSON becuse of it. The x-method-override of SYNC allows us to not need to provide the href of the record in question, just the unique key required for our framework to be able to find the record (ticketid & class in this case). I find this easier for integrations like this so you don't need to make a secondary call to retrieve the href.

    You had listed the createby as an email address but createby should correspond to a PERSONID in Maximo. I hardcoded this to MAXADMIN in my example for simplicity. Email listener would normally set the SENDFROM attribute to the email address it came from so I set that in my example. I also indicated that it was inbound to show that it wasn't sent from Maximo to the user but processed into Maximo. This has no functional impact, but I think it's helpful information for reporting purposes. 
    And if you did everything correctly you should see something like:


    We have some good REST API documentation here: Maximo's REST API (aka JSON API, OSLC API) - Asset & Facilities Management, especially the Maximo REST API Guide. It'll cover this and many more topics. 


    ------------------------------
    Steven Shull
    ------------------------------



  • 6.  RE: Is it possible to create a communication log entry via rest api?

    Posted Fri March 31, 2023 10:42 AM

    Thanks for the info! This is super helpful. I have everything setup but I am getting the following error on post. I am on MAS 8.9 BTW:

    BMXAA1339E - Missing key value for key COMMLOGID. Key value cannot be empty. Specify a value for the key and retry the operation.

    Any ideas? I thought it would create a new key?



    ------------------------------
    Christopher Stewart
    ------------------------------



  • 7.  RE: Is it possible to create a communication log entry via rest api?

    Posted Tue April 04, 2023 01:56 AM

    Hi Chris,

    This occurs where there is an extra space before your header property I think. You need to remove that and test. 





    ------------------------------
    Subhransu Sekhar Sahoo
    ------------------------------



  • 8.  RE: Is it possible to create a communication log entry via rest api?

    Posted Thu April 06, 2023 10:01 AM

    Thanks. I checked and do not see any spaces before the values. This is what is being sent. If I send an ID across it does work. For now I have defaulted an integer to an abbreviated date/time just to test, but would love to get this working without having to do that. 

                "x-method-override""SYNC",
                "patchtype""MERGE",


    ------------------------------
    Christopher Stewart
    ------------------------------



  • 9.  RE: Is it possible to create a communication log entry via rest api?

    Posted Thu April 06, 2023 10:06 AM

    COMMLOGID is typically setup to autonumber. Can you open COMMLOG in database configuration and go to the COMMLOGID attribute. It should look like my screenshot below.



    ------------------------------
    Steven Shull
    ------------------------------



  • 10.  RE: Is it possible to create a communication log entry via rest api?

    Posted Thu April 06, 2023 10:12 AM

    I think it all looks similar. 



    ------------------------------
    Christopher Stewart
    ------------------------------



  • 11.  RE: Is it possible to create a communication log entry via rest api?

    Posted Fri April 07, 2023 08:07 AM

    It looks like the issue with the ID happens when there is another commlog already created. If there are no commlogs the first one creates and generates an ID. If there is at least one I get the error asking me to provide an ID. 



    ------------------------------
    Christopher Stewart
    ------------------------------



  • 12.  RE: Is it possible to create a communication log entry via rest api?

    Posted Fri April 07, 2023 08:13 AM
    Edited by System Admin Tue August 22, 2023 04:33 PM

    Yep, I am seeing the same thing you are. Sorry in my test I didn't try to do it multiple times to the same SR. Add "_action":"Add" to the commlog record. That is working for me in quick tests as it will tell the framework up front we want to add this record.

    The body should look like:

    {
        "ticketid":"1001",
        "class":"SR",
        "commlog":[
            {
                "sendfrom":"myemail@company.com",
                "createby":"MAXADMIN",
                "subject":"This is your email subject",
                "message":"This is your email body",
                "inbound":true,
                "_action":"Add"
            }
        ]
    }



    ------------------------------
    Steven Shull
    ------------------------------



  • 13.  RE: Is it possible to create a communication log entry via rest api?

    Posted Mon April 10, 2023 08:52 AM

    That works! Thanks. I think we can call this one resolved.



    ------------------------------
    Christopher Stewart
    ------------------------------