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



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



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

    Posted Fri December 01, 2023 04:53 AM

    Hi,

    seems like your target URL does not like what you send. Turn on logger maximo.integration to DEBUG and watch the logs when clicking your button, perhaps this gives a bit more information



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



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

    Posted Fri December 01, 2023 05:06 AM
    Thank you very much once again.
     
    We included {0} in the message and received error 411, which means that the data we are sending is not in the database. Now we will contact another apartment to check.
     
    We will contact you with feedback.
    Jasmina


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



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

    Posted Mon December 04, 2023 03:29 AM
    Hello Andreas,
     
      just to let you know that we managed to solve the problem. We received a response from another application. We added only the lower function to one field, because the requester's codes are written in upper letters and theirs in lower letters, and that's why we had an error 411.
       This is an example of feedback:
    Now we need to enter the information we received in the answer into the field we have in Maximo (purchview.mxtconnum).
    Do you have any ideas for us?
     
    Thank you very much in advice.
    Best Regards
    Jasmina


    ------------------------------
    Jasmina Agic
    ------------------------------



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

    Posted Thu December 07, 2023 05:05 AM

    Hi Jamina,

    here we come to the field of absolutely basic scripting for maximo :)

    mbo.setValue("mxtconnum",result)

    For more information on this, refer to the Maximo Scripting Guide -> https://ibm-maximo-dev.github.io/maximo-autoscript-documentation/



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



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

    Posted Thu December 07, 2023 05:18 AM

    Hello Andreas,

    thank you very much. We set it up the same way and everything works fine.
     
    Thanks a lot for the help and instructions.
     
    Kind regards
     
    Jasmina


    ------------------------------
    Jasmina Agic
    ------------------------------



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

    IBM Champion
    Posted Sun December 03, 2023 10:44 AM

    Hi Jamina, 

    We have received this error code when we dont have SSL certificate available in Maximo websphere. 

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

    Could you please contact the team EcmService server which is hosting the service createOrUpdateDocument to provide the certificates. These certificates need to be uploaded in Maximo Websphere. 

    Please find the steps needed to do it. http://surenmaximoworks.blogspot.com/2023/08/ssl-connection-error-in-maximo.html

    Thanks, Suren



    ------------------------------
    Surendar Balasundaram
    ------------------------------



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

    Posted Mon December 04, 2023 03:35 AM
    Hello Surendar,
     
    thanks for your help. The certificate has already been loaded. We had a problem with another application. In the correspondence with Andreas, we made all the suggested corrections that Andreas sent us.
    We currently have a response from another application and now we need to enter that information in the field in Maximo.
     
    Thank you very much!
     
    Kind regards
    Jasmina


    ------------------------------
    Jasmina Agic
    ------------------------------