Need Help to Create the Business Workspaces using Rest API's
I have been trying to create the business workspaces using the Rest API's, But it keep on posting 400 bad request. kindly share rest api java code to resolve the issue. Please find my code for your reference.
public static void createBusinessWorkSpace(CloseableHttpClient client,
String cgiUrl, String ticket, int parentId, String folderName) throws UnsupportedEncodingException {
CloseableHttpResponse response = null; HttpPost request = new HttpPost("https://HostName/OTCS/cs.exe/api/v2/businessworkspaces/"); request.addHeader("OTCSTicket", ticket); // Provide all input parameters as JSON JSONObject input = new JSONObject(); input.put("parent_id", "218331"); input.put("name", "Testing"); input.put("description", "Testing"); input.put("template_id", "151915"); input.put("type", "848"); input.put("mime_type", "Business Workspace"); // Format body and file form fields to multipart/Form-data StringBody body = new StringBody(input.toString(), ContentType.APPLICATION_JSON); HttpEntity inputEntity = MultipartEntityBuilder .create() .addPart("body", body) .add .build(); request.setEntity(inputEntity); // Send the request and parse the JSON response try { response = client.execute(request); if(response.getStatusLine().getStatusCode()==200) { JSONObject output = getJSONOutput(response); } int status = response.getStatusLine().getStatusCode(); if (status != 200 && status != 201) { throw new IOException("Folder Created failed for \"" + folderName + "\""); } } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { response.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
0
Categories
- All Categories
- 108 Developer Announcements
- 53 Articles
- 106 General Questions
- 144 IM Services
- 43 OpenText Hackathon
- 32 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 899 Cloud Fax and Notifications
- 77 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 120 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management