Maximo Integration

 View Only
  • 1.  Sending File using POST using HTTP Handler

    Posted Mon March 21, 2022 11:47 AM
    I need to send a File using a POST to a external DMS system . The REST Call URL  is successful using this successful POSTMan snippet
    POST /dms/dmsrest/api/v1/externalsystems/PDMaximo1/botypes/ASSET/boids/BEDFORD:12100/documents HTTP/1.1
    Host: myserver.mydomain.com
    dmsticket: **AA*
    Cache-Control: no-cache
    Postman-Token: 5bcd1c67-2cb7-fc76-7d92-e93a771b5250
    Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

    ------WebKitFormBoundary7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="body"

    {"Name":"Appukili"}
    ------WebKitFormBoundary7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="file"; filename="helloworld.txt"
    Content-Type: text/plain


    ------WebKitFormBoundary7MA4YWxkTrZu0gW--

    The file I pick from my desktop using the POSTman control. I wrote a simple java class file simulating the POST without using any advanced libraries just URLConnection and that also is successful. I replicated the POSTman payload in that, I am trying to use a HTTPHandler. So in the header I stuffed the header you see in the POST example 
    I come to the TEST screen and put a *  I get this
    org.jdom.input.JDOMParseException: Error on line 1: Content is not allowed in prolog.
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:504)
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:807)
    at psdi.iface.util.XMLUtils.convertBytesToDocument(XMLUtils.java:309)
    at psdi.iface.app.endpoint.MaxEndPointTestSet.execute(MaxEndPointTestSet.java:126)

    When I read the documentation of this handler it says the TEST screen has to have valid XML so if I fake a XML struct then the message changes something like this
    So in closing if my REST API needs multipart formdata and the file that needs to go out also has to be specified 
    will HTTPHandler be the right one or would I extend this and change the headers and also add the multipart form data
    myself as my standalone java class does?
    Does the Tester expect XML to be put there ?  
    is there a simple example for me to follow
    I registered a free weathermap key as well


    http://api.openweathermap.org/data/2.5/uvi/forecast?lat=-33.8688&lon=151.2093&cnt=7&appid=58ae6a7dfeb1eda54
    this works in browser but not in the HTTPHandler 

    Any help you can point out is appreciated :) this is Maximo 7.6.1.2




    ------------------------------
    Appu Nair
    ------------------------------


  • 2.  RE: Sending File using POST using HTTP Handler

    Posted Thu April 21, 2022 09:15 AM
    In the interest of completeness I actually coded the POST myself as I wasn't able to fully understand the myriad lines in the 
    HTTP handler which I decompiled for understanding.

    ------------------------------
    Appu Nair
    ------------------------------