AnsweredAssumed Answered

Missing content when create a document

Question asked by lelejill on Jun 25, 2009
Latest reply on Sep 9, 2009 by walley
Hi,

I want to create a document by using: POST /alfresco/service/api/path/{store_type}/{store_id}/{id}/children

I can create it successfully in my space, but when I click on the document I create to see the content of it,

the following message comes up:

The node's content is missing:
   node: workspace://SpacesStore/42a0172c-32af-43c1-9045-9c511f3e5181
   reader: null 
Please contact your system administrator.

It seems there is sth wrong in my Atomentry xml to parse the content src.

Here is my java test 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 CreateDocPost {

   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 ="D:/createdocpost.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();
      }
   }
}


Here is my Atomentry sample xml:
<?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/document'/>
<link rel="repository" href="http://localhost:8080/alfresco/service/api/repository'/>
<title>createDoc.txt</title>
<summary>create doc test Summary</summary>
<content type="text/plain" src="D:/joe.txt" />
<cmis:object>
<cmis:properties>
<cmis:propertyId cmis:name='ObjectTypeId'><cmis:value>document</cmis:value></cmis:propertyId>
</cmis:properties>
</cmis:object>
</entry>

Can anybody here help me out?

Thanks a lot

Xiaole

Outcomes