AnsweredAssumed Answered

New to web script...please help

Question asked by vjayabalan on Aug 5, 2011
Latest reply on Sep 1, 2011 by brogits
Hello everyone,

I am new to web scripts. I am trying to create a folder under Company Home in my Alfresco repository. I am using the following code to execute a POST method that would create the folder:

String url = "http://localhost:11080/alfresco/service/cmis/pCompany%20Home/children"
PostMethod method = new PostMethod(url)
String filePath = "C:/testDoc.xml";
String contentType = "application/atom+xml;type=entry";
File upload = new File(filePath);
method.setRequestHeader("name", upload.getName());
method.setRequestHeader("Content-type", contentType);
method.setRequestBody(new FileInputStream(upload));
      int respCode = client.executeMethod(method)
catch(IOException io){
catch(HttpException hte){

The testDoc.xml looks like this (I found it online :)):

<?xml version='1.0' encoding='utf-8'?>
<entry xmlns='' xmlns:cmis=''>
<title>VJ Folder</title>
<summary>VJ's folder</summary>
<content type="text/html">${CONTENT}</content>
<cmis:propertyString cmis:name='ObjectTypeId'><cmis:value>folder</cmis:value></cmis:propertyString>

When I run the code, I get the following exception. I don't want to bore you with the complete error message, but here is a snippet:

            <tr><td><b>404 Description:</b></td><td> Requested resource is not available.</td></tr>
            <tr><td> </td></tr>
            <tr><td><b>Message:</b></td><td>Cannot find object for ObjectPathReference[storeRef=workspace://SpacesStore,path=/app:company_homeCompany Home]</td></tr>
            <tr><td><b>Server</b>:</td><td>Community v3.4.0 (d 3370) schema 4,113</td></tr>
            <tr><td><b>Time</b>:</td><td>Aug 4, 2011 5:10:14 PM</td></tr>
            <tr><td></td><td> </td></tr>
            <tr><td><b>Diagnostics</b>:</td><td><a href="/alfresco/service/script/org/alfresco/cmis/">Inspect Web Script (org/alfresco/cmis/</a></td></tr>

I don't know what I am doing wrong here. Please help!