Maximo

 View Only
Expand all | Collapse all

Problem with integration script (POST API metod)

  • 1.  Problem with integration script (POST API metod)

    Posted Wed November 29, 2023 09:18 AM
      |   view attached
    Hello Everyone
     
    I have a problem connecting Maximo with an external application via REST-API methods. We have Maximo 7.6.1 version installed. It is necessary to send the fields from the contract module from Maximo and to return information based on those fields that should be loaded into the field in maximo
    When we test the POST method (documentation and link that we received from our partner), it returns the information properly through Postman.
    In maximo, we created a script that is activated by clicking a button. We don't have much experience with this so if someone can help us.
    I am sending the script in attachment.
     
    Thanks in advance!
     
    Lp
    Jasmina



    ------------------------------
    Jamina Agic
    ------------------------------

    Attachment(s)

    txt
    maximo_skripta.txt   3 KB 1 version


  • 2.  RE: Problem with integration script (POST API metod)

    Posted Fri December 01, 2023 02:40 AM
    Edited by Andreas Brieke Fri December 01, 2023 02:49 AM

    Hi Jamina,

    i would say it doesn't look wrong. What is the error you get?

    Just as a tip:
    I personally would use an Endpoint (Integration -> End Points), so you can store the Password encrypted and don't have to handle all the connection settings.

    from com.ibm.json.java import JSONObject
    from java.util import HashMap
    
    request_data = JSONObject()
    request_data.put("opisUsluge", mbo.getString("DESCRIPTION"))
    request_data.put("brojOdobrenja", mbo.getString("MXTCONNUM"))
    request_data.put("mjestoTroska", mbo.getString("MXTMJESTTRO"))
    request_data.put("nazivDobavljaca", mbo.getString("VENDOR"))
    request_data.put("jibDobavljaca", mbo.getString("VENDOR.REGISTRATION1"))
    request_data.put("odobravatelj", mbo.getString("MXTNABZAH"))
    request_data.put("opu", mbo.getString("MXTPERSON.DEPARTMENT"))
    request_data.put("buc", mbo.getString("MXTPERSON.MXTPERBUC"))
    request_data.put("iznosBezPdv", mbo.getFloat("TOTALCOST"))
    request_data.put("iznosSaPdv", mbo.getFloat("MXTTOTALPDV"))
    request_data.put("delovodnikId", "KP")
    request_data.put("nacinKreiranja", "INTERNAL")
    request_data.put("tipDokumenta", "ecm:ugovor")
    request_data.put("nacinPrijema", "1")
    request_data.put("stepenPoverljivosti", "pov-interno")
    request_data.put("ojKreiranja", "01")
    jsonString = request_data.serialize(False)
    
    ctx = HashMap()
    ctx.put("ERRORONSTATUS",False)
    ctx.put("ALLRESPONSEHEADERS",True)
    result =service.invokeEndpoint("<EndPointName>", ctx, jsonString)
    if ctx.get("RESPONSE_HEADERS").get("RESPONSE_STATUS") == "200":
        service.error("<ErrorGroup>","<ErrorKey>",[result])
    else:
        service.error("<ErrorGroup>","<ErrorKey>",[ctx.get("RESPONSE_HEADERS").get("RESPONSE_STATUS")])

    The one thing i am wondering about is why you want to throw an error and if you are using ErrorGroup/ErrorKey correct. ErrorGroup/ErrorKey normally refers to a message you defined in Databaseconfig -> Messages. If the message you want to show does not exist you get an error like "Succesful response: #200" shown.



    ------------------------------
    Andreas Brieke
    IT Service Management Consultant
    SVA System Vertrieb Alexander GmbH
    ------------------------------



  • 3.  RE: Problem with integration script (POST API metod)

    Posted Fri December 01, 2023 03:55 AM
    Hello Andreas,
     
    thank you very much for your help.
     
    We did everything you suggested and after the test we get an error.
    I am sending all the pictures in the attachment.
     
    We have three virtual machines. One is ours on which the maximo application is installed, the other is exadata where the database (oracle database) is located and on the third machine there is an application that needs to return a number, i.e. (information).
    I don't know if it's a network problem. From the server where the application is, we regularly ping the server where we send the data. On the server where the base is, they also checked and said that it was released on port 8080.
    We tested it through Postman and it works properly. I am sending the pictures in the attachment.
     
    Thanks again for any suggestions.
     
    Lp
    Jasmina


    ------------------------------
    Jamina Agic
    ------------------------------



  • 4.  RE: Problem with integration script (POST API metod)

    Posted Fri December 01, 2023 04:27 AM

    Hi Jamina,

    include in your messages a {0} so Maximo knows that it shall put the first value from the given parameters on this place.

    If there is an error in the connection, set ERRORONSTATUS to True and the endpoint will give you some more information

    ctx.put("ERRORONSTATUS",True)


    ------------------------------
    Andreas Brieke
    IT Service Management Consultant
    SVA System Vertrieb Alexander GmbH
    ------------------------------



  • 5.  RE: Problem with integration script (POST API metod)

    Posted Fri December 01, 2023 04:46 AM

    Thank you very for a quick reply!

    Now we get this error:

    BMXAA1482E - the response code received from the http request from the endpoint is not successful.

    Jasmina

    </