AnsweredAssumed Answered

Missing content when create a document

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

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 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) {

Here is my Atomentry sample xml:
<?xml version='1.0' encoding='utf-8'?>
<entry xmlns="" xmlns:app="" xmlns:cmis="" xmlns:alf="">
<link rel="type" href="http://localhost:8080/alfresco/service/api/type/document'/>
<link rel="repository" href="http://localhost:8080/alfresco/service/api/repository'/>
<summary>create doc test Summary</summary>
<content type="text/plain" src="D:/joe.txt" />
<cmis:propertyId cmis:name='ObjectTypeId'><cmis:value>document</cmis:value></cmis:propertyId>

Can anybody here help me out?

Thanks a lot