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.