Creating multiple objects in Documentum through Documentum Rest services.

viv@31
edited July 23, 2017 in Documentum #1

Hi All,

We have a requirement to create a multiple documents through documentum rest services in single POST call .we are using below code to create a single document in repository.

public class RestClient{

public static void main(String args[]){

try{

System.out.println("In main");

RestClient rc = new RestClient();

rc.testRestClient();

}

catch(Exception ex){

System.out.println("exception is : "+ex.getMessage());

}

}

@SuppressWarnings("deprecation")

public void testRestClient() throws ClientProtocolException, IOException

{

String path = "http://SERVER/dctm-rest/repositories/REPOS/folders/OBJECT_ID/documents";

String auth = "Basic " + "*******";

String json = "{\"properties\" : {\"object_name\" : \"TEST\", \"r_object_type\" :\"dm_document\"}}";

HttpClient client = new DefaultHttpClient();

HttpPost post = new HttpPost(path);

post.addHeader("Authorization", auth);

MultipartEntityBuilder builder = MultipartEntityBuilder.create();

MultipartEntityBuilder builder1 = MultipartEntityBuilder.create();

builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);

builder.addPart("data", new StringBody(json, "application/vnd.emc.documentum", Charset.forName("UTF-8")));

//builder.addBinaryBody("binary", byteArray, ContentType.create("application/pdf"), "test.pdf");

URL rest = new URL("http://Server:8080/dctm-rest/repositories/REPOS/objects/OBJECT_ID/content-media?format=pdf&modifier=&page=0");

URLConnection uc = rest.openConnection();

uc.setRequestProperty("Authorization", "Basic " + "************");

InputStream content = uc.getInputStream();

builder.addBinaryBody("binary", content, ContentType.create("application/pdf"), "test.pdf");

HttpEntity entity = builder.build();

post.setEntity(entity);

HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();

HttpResponse response = httpClientBuilder.build().execute(post);

System.out.println("Respsone is "+response.toString());

}

}

Can you let me know is there any way to pass multiple create request in single HTTP POST call?

Thanks,

vivek.

Best Answer

  • abc123
    edited July 23, 2017 #2 Answer ✓

    Let me put all together.

    1. If you want to import multiple contents for different documents, it's recommended to use Batches Resource (REST 7.3+).
    2. If you want to import multiple contents for a single document, it's recommended to make multipart POST directly on Folder Child Objects Resource or Folder Child Documents Resource. (REST 7.3+)

    Here is a Postman example for (2).

    • At least specify parameters content-count, all-primary and format
    • Select form-data format
    • The 1st part is a JSON object containing properties
    • The 2nd part and all following parts are contents, either from input texts or from files.

    import-multipart.png

    Content import in Batches Resource is supported in REST 7.3.

    Multi content import for a single document is supported in REST 7.3.

Answers

  • abc123
    edited July 19, 2017 #3

    By REST 7.3 Batches service, you can create multiple documents / contents in a single HTTP call. Please refer to REST 7.3 service reference guide and developer guide. Here is an introduction page for Batches service in 7.2, , but 7.2 does not support multi content import in batches.

  • viv@31
    edited July 19, 2017 #4

    https://community.emc.com/docs/DOC-42227  here I can see sample payload json request to create multiple documents in repository .

    Is it possible to create multiple content by following this?

  • abc123
    edited July 20, 2017 #5

    It's possible to create multiple contents for a single document in one HTTP multipart request since from REST 7.3 release.

  • viv@31
    edited July 20, 2017 #6

    I have a little confusion with content and document referred here,  My requirement is I need to import multiple documents like PDF or TEXT files into documentum in single POST call.

    Can you please let me know ,Is this can be achieved through 7.2 ?,If possible can you guide us to the reference links or JSON requests can be used to achieve this.

  • abc123
    edited July 23, 2017 #7 Answer ✓

    Let me put all together.

    1. If you want to import multiple contents for different documents, it's recommended to use Batches Resource (REST 7.3+).
    2. If you want to import multiple contents for a single document, it's recommended to make multipart POST directly on Folder Child Objects Resource or Folder Child Documents Resource. (REST 7.3+)

    Here is a Postman example for (2).

    • At least specify parameters content-count, all-primary and format
    • Select form-data format
    • The 1st part is a JSON object containing properties
    • The 2nd part and all following parts are contents, either from input texts or from files.

    import-multipart.png

    Content import in Batches Resource is supported in REST 7.3.

    Multi content import for a single document is supported in REST 7.3.

  • Hi,

    Are you able to get payload for the PDF or Text files.

    Vinod Krishna
    Architect, Consulting Services
    OpenText