0

I am looking to interact with a Documentum Repository using their REST API. I would like to use the http-client 4.3 jars to perform this interaction.

I was hoping someone might have a sample that would help point me in the correct direction on how to interact with DCTM.

I am having trouble finding a clear and simple example of how to do this.

Thanks

purring pigeon
  • 4,141
  • 5
  • 35
  • 68

1 Answers1

3

I know it is a bit late to answer this question. But i want to answer to help those who still need a code for making requests to the rest api. Here is a full example of sending a post request to the rest api for starting a workflow.

For other needs you can check the Document called Documentum xCP Rest Services provided by EMC : https://support.emc.com/docu52500_Documentum-xCP-REST-Services-2.1-Development-Guide.pdf?language=en_US&request=akamai and compare with this example, change it according to it's needs.

UPDATE:

Also if you are not using xcp here is the Documentation for rest api without it emc.com/collateral/TechnicalDocument/docu57895.pdf

You can also check my answer here How can I use REST to copy an object in Documentum 7.x for geting object data and content from the rest api ( without xcp )

    String strResponse = "";

    String process_id = "system_name of the process you want to start";

    String url = "Your App Url Here/processes/" + process_id;

    String json = "{"+
        "\"run-stateless\" : \"false\","+
        "\"data\" :"+
        "   { "+
        "       \"variables\" : "+
        "           {   \"Variable name\" : \"Variable value\" } "+
        "   } "+
        "}";

    CloseableHttpClient httpClient = HttpClientBuilder.create().build();

    BufferedReader rd = null;
    CloseableHttpResponse cls = null;
    try {
        HttpPost request = new HttpPost(url);

        // set timeouts as you like
        RequestConfig config = RequestConfig.custom()
                .setSocketTimeout(60 * 1000).setConnectTimeout(20 * 1000)
                .setConnectionRequestTimeout(20 * 1000).build();

        request.setConfig(config);

        StringEntity params = new StringEntity(json);

        request.addHeader("Accept", "application/json");

        request.addHeader(
                "Authorization",
                "Basic "
                        + com.documentum.xmlconfig.util.Base64
                                .encode("username here" + ":"
                                        + "password here"));

        request.addHeader("Content-Type", "application/vnd.emc.xcp+json");

        request.setEntity(params);

        try {

            cls = httpClient.execute(request);

            HttpEntity entity = cls.getEntity();

            rd = new BufferedReader(new InputStreamReader(
                    entity.getContent()));
            String line = "";
            while (line != null) {
                line = rd.readLine();
                strResponse += line;
            }

            strResponse = strResponse.trim().replace("\n", "");

            String statusline = cls.getStatusLine().toString();
            if (!statusline.contains("200") && !statusline.contains("201")) {

                Log.write("Process is not started");
                // log the strResponse or do something with it

            } else {
                System.out.println("Process started successfully");
            }

        } catch (Exception e) {

            e.printStackTrace();
        }

    } finally {

        // using commons-io-2.4.jar
        IOUtils.closeQuietly(httpClient);
        IOUtils.closeQuietly(cls);
        IOUtils.closeQuietly(rd);

    }
Community
  • 1
  • 1
AhmetRasitBekar
  • 348
  • 2
  • 12