Maximo Open Forum

 View Only
Expand all | Collapse all

Script to send the data to external system using automation script without any endpoint

  • 1.  Script to send the data to external system using automation script without any endpoint

    Posted 10-11-2023 15:07

    Hello all,

    we have a requirement to call external client using their URL and send the workorder data through automation script without using any endpoints or MIF.
    I am using the below code to execute the above request but I am not able to succeed, can anyone please suggest or correct my code.
    Thanks in advance

    import java.io.OutputStream;
    import java.net.URL;
    import java.net.HttpURLConnection;
    import org.json.JSONObject;
     
     
    URL url;
    String api_url = "http://demo.qellus.com:80/maxrest/rest/os/MXWO?wonum='5004'&status='APPR'";
    String username = "maxadmin";
    String password = "maxadmin";
     
    try {
        MXServer mxServer = MXServer.getMXServer();
        MboSet mboSet = mxServer.getMboSet("WORKORDER");
        Mbo mbo = mboSet.getMbo(0);
     
        String wonum = mbo.getString("wonum");
        String status = mbo.getString("status");
        String description = mbo.getString("description");
        JSONObject data = new JSONObject();
        data.put("wonum", wonum);
        data.put("status", status);
        data.put("description", description);
     
        String json_data = data.toString();
     
        url = new URL(api_url);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "application/json");
        connection.setRequestProperty("Accept", "application/json");
        connection.setDoOutput(true);
        OutputStream outputStream = connection.getOutputStream();
        outputStream.write(json_data.getBytes("UTF-8"));
        outputStream.flush();
     
        
    } catch (Exception e) {
        e.printStackTrace();
    }

    #Customizations

    ------------------------------
    Prathyusha Mukku
    LNT
    ------------------------------


  • 2.  RE: Script to send the data to external system using automation script without any endpoint

    Posted 10-12-2023 18:25

    Your code looks like Java, not autoscript.

    For automation script, if you don't like to invoke an End Point to send an HTTP request, you can try the psdi.iface.router.HTTPHandler class. I have some example code here in this post 

    If you are still stuck after trying these, feel free to let me now



    ------------------------------
    Viet Tran
    Relia
    ------------------------------