cancel
Showing results for 
Search instead for 
Did you mean: 

createFolder

adn741
Champ in-the-making
Champ in-the-making
Hi,

I am new in CMIS and I try to implement some functions in php.

I try to create a Folder in another one.

I send the following http request and I always have a 400 error (bad request):

POST /alfresco/s/api/path/workspace/SpacesStore/Company%20Home/children HTTP/1.1
Host: share.alfresco.com
User-Agent: PEAR HTTP_Request class ( http://pear.php.net/ )
Connection: close
Authorization: Basic YWRuNzQxOlcxcjJkNm84
Content-Type: text/xml; charset=utf-8
Content-Length: 726
<?xml version="1.0" encoding="UTF-8"?>
<createFolder xmlns:cmis="http://www.cmis.org/2008/05" xmlnsSmiley Tongue="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cmis.org/2008/05 CMIS.xsd ">
<cmis:repositoryId>192f0f98-98a0-4986-acce-4d8413c5054c</cmis:repositoryId>
<cmis:typeId>folder</cmis:typeId>
<cmisSmiley Surprisedbject>
<cmisSmiley Tongueroperties>
<cmisSmiley TongueropertyId cmis:name="ObjectTypeId">
<cmis:value>folder</cmis:value>
</cmisSmiley TongueropertyId>
<cmisSmiley TongueropertyString cmis:name="Name">
<cmis:value>Le nom de mon dossier</cmis:value>
</cmisSmiley TongueropertyString>
</cmisSmiley Tongueroperties>
</cmisSmiley Surprisedbject>
<cmis:folderId>e732596d-84a4-4773-851a-0a007cc27367</cmis:folderId>
</createFolder>

If somebody could help me, I really don't understand why

Thanks

Dan
2 REPLIES 2

lakshya
Champ in-the-making
Champ in-the-making
did u find the solution???

lelejill
Champ in-the-making
Champ in-the-making
Hi adn741,

Here is my code sample using almost the same api with yours:  POST /alfresco/service/api/path/{store_type}/{store_id}/{id}/children,
It works well in my local env.  Hope it helps!


java code:

import java.io.File;
import java.io.FileInputStream;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.bouncycastle.util.encoders.Base64;

public class CreateFolderPost {

   public static void main(String[] args) {

      try {
         String url ="http://localhost:8080/alfresco/service/api/path/workspace/SpacesStore/Company%20Home/Sites/children";
         String creds = "admin" + ":" + "admin";
         HttpClient httpClient = new HttpClient();
         PostMethod method = new PostMethod(url);
         method.setRequestHeader("Authorization", "Basic "
          + new String(Base64.encode(creds.getBytes())));

         String filePath ="createfolderpost.xml";
         String contentType = "application/atom+xml;type=entry";
         File createDoc = new File(filePath);
         method.setRequestHeader("name", createDoc.getName());
         method.setRequestHeader("Content-type", contentType);
         method.setRequestBody(new FileInputStream(createDoc));
         int status = httpClient.executeMethod(method);
         System.out.println("return code is: " + status + "\n\n" + " return body is :"
               + method.getResponseBodyAsString());

      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}

createfolderpost.xml sample:

<?xml version='1.0' encoding='utf-8'?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200901" xmlns:alf="http://www.alfresco.org">
<link rel="type" href="http://localhost:8080/alfresco/service/api/type/folder'/>
<link rel="repository" href="http://localhost:8080/alfresco/service/api/repository'/>
<title>sales</title>
<summary>sales space</summary>
<cmis:object>
<cmis:properties>
<cmis:propertyId cmis:name="ObjectTypeId"><cmis:value>folder</cmis:value></cmis:propertyId>
</cmis:properties>
</cmis:object>
</entry>
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.