Maximo

Expand all | Collapse all

Acessing External System REST API Using Maximo Automation Scripts

  • 1.  Acessing External System REST API Using Maximo Automation Scripts

    Posted 7 days ago
    I know there are lots of great material out there that showcase the power of Maximo REST API. But my question here is using Maximo automation script, how can we access another external systems Rest API. How to append the header details, the payload, etc. It would be great to share any sample scripts.

    ------------------------------
    keshav ravindran
    ------------------------------


  • 2.  RE: Acessing External System REST API Using Maximo Automation Scripts

    Posted 7 days ago
    An example of exactly what you're looking for from IBM:

    https://www.ibm.com/support/pages/maximo-rest-client-example-calling-external-rest-service-logo-tiger-3-maximo-client

    ------------------------------
    Frank Tate
    Gulfsoft Consulting
    ------------------------------



  • 3.  RE: Acessing External System REST API Using Maximo Automation Scripts

    Posted 7 days ago
    Hi,
    It is not always a viable solution but if possible IMO the best approach is to map the REST API to a federated object:
    https://www.ibm.com/support/pages/federated-mbo-integration

    ------------------------------
    Diego Visentin
    EAM BU Director
    Tempestive S.p.A.
    Pordenone
    ------------------------------



  • 4.  RE: Acessing External System REST API Using Maximo Automation Scripts

    Posted 7 days ago

    I would suggest utilizing Maximo end points. Maximo is designed to handle HTTP connections from an integration perspective, and it handles an abstracts a lot of the code portion while still giving you almost complete control of the connection. You don't need any additional libraries to be downloaded, and you know it will continue to be supported by IBM. It also gives you a good place to store information about your integration while allowing the script to override anything that is necessary. For example, we integrate with a monitoring system in two ways (retrieve monitoring IDs and another to schedule downtime for maintenance events). We're able to store the pieces that are constant in the endpoint, and override what we need to change for that particular integration (such as using a POST request instead of a GET request). 

    Federated MBOs that Diego mentioned is also a good system for certain integrations, especially if you're just retrieving information, but doesn't make sense in all cases. There's overhead in setting up a MBO that isn't necessary if you're just trying to process it in an automation script for example. And if you need to be able to update these MBOs, you have to build your own logic to push updates anyways.

    I had a response on the old forums that I'm struggling to find. This was written pretty quick, so if there are questions on it please let me know.

    The first thing you have to do is declare your endpoint in the End Points application. Create a new end point and ensure the handler is HTTP. Provide what you can in the end point configuration (such as URL, HTTP METHOD, headers, etc.). Anything that you need to set in the script, ensure that the Allow Override checkbox is checked. I've shown an example below that we use. If your service uses basic authentication, you can provide the username/password fields and it will handle that, otherwise leave those two fields null.

    Example end point
    In your script, you need to import the Router if you aren't on a newer version of 7.6 (where IBM added some additional methods on the service implicit variable to do this). You also need Java's string & HashMap imported as well.

    from psdi.iface.router import Router
    from java.util import HashMap
    from java.lang import String

    You then need to build a HashMap to override any of the properties you need to, such as HEADERS, and a body for your request (unless it's intended to be null). We built a basic handler function which I've copied below. Handler corresponds to you retrieving your endpoint, such as 
    Router.getHandler("EMXSITE24X7"). We add in the ERRORONSTATUS to our property overrides to prevent an actual exception being thrown, since we'll process the response for the issue. RESPONSE_HEADERS allows us to capture the response data to get the actual response code from the integration. In our case, anything under 400 is successful, but you may want to look at specific statuses to handle based on the integration referenced. 

    Assuming that your response is JSON, you can easily cast it into a JSONObject to make processing easier. You have to import:
    from com.ibm.json.java import JSONObject and then can do something like this: 

    responseObject=JSONObject.parse(response)

    and then access the different pieces like responseObject.get("token") if there is a JSON attribute named token. 

    def invokeEndpoint(handler,map,body):
        success = False
        response = None
        errorResponse = HashMap()
        errorMessage=""
        map.put("ERRORONSTATUS",False)
        map.put("RESPONSE_HEADERS",errorResponse)
        
        try:
            response=String(handler.invoke(map,body))
            if int(errorResponse.get("RESPONSE_STATUS"))<400:
                success=True
        except:
            errorMessage = "Error: " + str(sys.exc_info()[0]) + ". Message: " + str(sys.exc_info()[1])
        return success, errorMessage, response


    ------------------------------
    Steven Shull
    Director of Development
    Projetech Inc
    Cincinnati OH
    ------------------------------



  • 5.  RE: Acessing External System REST API Using Maximo Automation Scripts

    Posted 7 days ago

    Regarding:  "Create a new end point and ensure the handler is HTTP."

    Have you found that HTTPS does not work? If so, do you know why?



    ------------------------------
    Thanks
    ------------------------------



  • 6.  RE: Acessing External System REST API Using Maximo Automation Scripts

    Posted 7 days ago
    Edited by Diego Visentin 7 days ago
    What is the exception in system logs? 
    Anyway, check this https://www.ibm.com/support/pages/unable-send-outbound-transactions-over-ssl and if there is no problem for WAS to handle the destination certification (e.g. if it's a self-signed, you must import into WAS)

    ------------------------------
    Diego Visentin
    EAM BU Director
    Tempestive S.p.A.
    Pordenone
    ------------------------------



  • 7.  RE: Acessing External System REST API Using Maximo Automation Scripts

    Posted 7 days ago

    All of our end points are HTTPS. There are a couple of areas that could impact people. The most common is WebSphere doesn't trust certificates unless added to the trust store.


    Beyond that, certificates greater than 2048 bits weren't allowed without replacing some policy files until relatively recent. I know with WebSphere 9 and Java 1.8 it is no longer required, not sure which earlier versions it was fixed in.

    The final thing is WebSphere 8.5.5 by default doesn't support TLS 1.2 for outbound connections which is now becoming a requirement. This was changed in WebSphere 9 but is an easy change to make in 8.5.5.

    Those are the most common things we've seen.



    ------------------------------
    Steven Shull
    Director of Development
    Projetech Inc
    Cincinnati OH
    ------------------------------



  • 8.  RE: Acessing External System REST API Using Maximo Automation Scripts

    Posted 7 days ago
    Here is a related post:

    Maximo/GIS spatial query
    https://stackoverflow.com/a/57730617/10936066

    Also, take a look at page 2 in this PDF:  Maximo 76 Scripting Features:

    https://www.ibm.com/developerworks/community/wikis/form/anonymous/api/wiki/02db2a84-fc66-4667-b760-54e495526ec1/page/03ad118c-6040-43dd-bc6d-d7a03510d135/attachment/1004fd2b-1b51-411e-8df0-a8b02ca86272/media/Scritping76Features%20%285%29.pdf


    ------------------------------
    Thanks
    ------------------------------



  • 9.  RE: Acessing External System REST API Using Maximo Automation Scripts

    Posted 7 days ago
    hi, you will implement an invocation channel to interact with a remote endpoint. Details are specific to the requirements. hth -Keith-

    ------------------------------
    keith simmons
    ------------------------------



  • 10.  RE: Acessing External System REST API Using Maximo Automation Scripts

    Posted 6 days ago
    Thanks for the question , Keshav.
    Are you looking to send Maximo data by invoking an external application API  ? You can very well achieve it by using MIF.

    All you need is setup an HTTP end point in Integration-> End points with PUT or POST method, followed by a publish channel and External application.
    If you wish to proceed with automation script approach, here is the link--> https://www.ibm.com/support/pages/node/1129845
    Maximo Rest Client Example: Calling an External REST Service (Logo Tiger 3) with a Maximo Client

    The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com