AnsweredAssumed Answered

Search through REStful Api

Question asked by lakshya on Jan 27, 2009
Latest reply on Aug 1, 2009 by lakshya
Hello,
I need to run POST /alfresco/service/api/query

Code I have written for it is :
       URL = "http://localhost:8081/alfresco/service/api/query";
       PostMethod method = new PostMethod(URL);
       String filePath = "query.xml";
       String contentType = "application/atom+xml;type=query"; // tried with "application/cmsrequest+xml;type=query" also

       File upload = new File(filePath);      
       method.setRequestHeader("name", upload.getName());
       method.setRequestHeader("Content-type", contentType);
       method.setRequestBody(new FileInputStream(upload));
       client.executeMethod(method);
       System.out.println(method.getResponseBodyAsString());

and query.xml is:
<?xml version="1.0"?>
<query xmlns="http://www.cmis.org/CMIS/2008/05">
    <statement>SELECT * FROM document</statement>
   <searchAllVersions>false</searchAllVersions>
    <pageSize>0</pageSize>
    <skipCount>0</skipCount>
    <returnAllowableActions>false</returnAllowableActions>
    </query>

I am getting the following error:
org.alfresco.service.cmr.repository.TemplateException -
Error during processing of the template 'Expression statement is undefined on line 12, column 58 in org/alfresco/repository/search/query.post.atomfeed.ftl.'. Please contact your system administrator.</td></tr>

Can anyone help me out to get the way for sending query through RESt.

Regards,

Outcomes