AnsweredAssumed Answered

Unable to run start-workflow webscript

Question asked by veda on Feb 18, 2013
Latest reply on Feb 19, 2013 by mitpatoliya
Hi All,

I'm having problem while running start-workflow webscript using REST API in alfresco 4.2 b version.

I have written code like this….i'm able to run start-workflow webscript in alfresco3.4 version with same code.

public String startWorkflow(String alfrescoUrl, String ticket)
{
     String resp = null;
     try
     {
       
       // http://localhost:8080/alfresco/service/imap/start-workflow?alfTicket={ticket}&nodeRefId={id}&workflowType={wt}&assignTo={at}&workflowDueDateDay={ddd}&workflowDueDateMonth={ddm}&workflowDueDateYear={ddy}&description={desc}&workflowPriority={wp?}
          
            HttpClient client = new HttpClient();
              client.getParams().setAuthenticationPreemptive(true);
              client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("admin", "password"));
            
     String url = (new StringBuilder()).append(alfrescoUrl).append("/alfresco/service/imap/start-workflow").toString();
     System.out.println("url"+url);

     String nodeRefId = null;
    
     Object objectId = getDocument("csuite");
     if (objectId != null)
     {       
         String workspaceId = null;
         String storeId = null;
         String nodeId = null;
        
         StringTokenizer tokenizer = new StringTokenizer(objectId.toString(), ":/");
         workspaceId = tokenizer.nextToken();
         storeId = tokenizer.nextToken();
         nodeId = tokenizer.nextToken();
        
         nodeRefId = workspaceId + "://" + storeId + "/" + nodeId;
     }   
     System.out.println("nodeRefId"+nodeRefId);

     HttpMethod method = new GetMethod(url);
     NameValuePair nvp1 = new NameValuePair("alfTicket", ticket);
     NameValuePair nvp2 = new NameValuePair("nodeRefId", nodeRefId);
     NameValuePair nvp3 = new NameValuePair("workflowType", "jbpm$review");
     NameValuePair nvp4 = new NameValuePair("assignTo", "admin");
     NameValuePair nvp5 = new NameValuePair("workflowDueDateDay", "31");
     NameValuePair nvp6 = new NameValuePair("workflowDueDateMonth", "03");
     NameValuePair nvp7 = new NameValuePair("workflowDueDateYear", "9999");
     NameValuePair nvp8 = new NameValuePair("description", "test workflow");
     NameValuePair nvp9 = new NameValuePair("workflowPriority", "2");
     method.setQueryString(new NameValuePair[] {
         nvp1, nvp2, nvp3, nvp4,nvp5,nvp6, nvp7
     });
     method.setDoAuthentication(true);
     int statusCode = client.executeMethod(method);
     resp = method.getResponseBodyAsString();
     //org.codehaus.jettison.json.JSONObject obj = new org.codehaus.jettison.json.JSONObject(method.getResponseBodyAsString());
     //net.sf.json.JSONObject jsonObj = net.sf.json.JSONObject.fromObject(method.getResponseBodyAsString());
     method.releaseConnection();    
     }
     catch(UnsupportedEncodingException ue)
     {
         ue.printStackTrace();
     }
     catch(IOException ioe)
     {
         ioe.printStackTrace();
     }
     catch(Exception e)
     {
         e.printStackTrace();
     }
   
     return resp;
}

I changed the code for workflow type

NameValuePair nvp3 = new NameValuePair("workflowType", "activiti$acitivitiReview");

I'm getting error as below…



  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <title>Web Script Status 404 - Not Found</title>
      <link rel="stylesheet" href="/alfresco/css/webscripts.css" type="text/css" />
   </head>
   <body>
      <div>
         <table>
            <tr>
               <td><img src="/alfresco/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
               <td><span class="title">Web Script Status 404 - Not Found</span></td>
            </tr>
         </table>
         <br/>
         <table>
            <tr><td>The Web Script <a href="%2Falfresco%2Fservice%2Fimap%2Fstart-workflow%3FalfTicket%3DTICKET_9d526f178f1709ce6621e94981d2139eea50dbf7%26nodeRefId%3Dworkspace%3A%2F%2FSpacesStore%2F646dd03f-2fd2-4d52-b4d8-cfe3f0e54b09%2Fcsuite-alfresco1.docx%26workflowType%3Djbpm%24review%26assignTo%3Dadmin%26workflowDueDateDay%3D31%26workflowDueDateMonth%3D03%26workflowDueDateYear%3D9999">/alfresco/service/imap/start-workflow</a> has responded with a status of 404 - Not Found.</td></tr>
         </table>
         <br/>
         <table>
            <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>Content with NodeRef id 'workspace://SpacesStore/646dd03f-2fd2-4d52-b4d8-cfe3f0e54b09' not found.</td></tr>
            <tr><td><b>Server</b>:</td><td>Community v4.2.0 (4471) schema 6,020</td></tr>
            <tr><td><b>Time</b>:</td><td>Feb 18, 2013 5:44:07 PM</td></tr>
            <tr><td></td><td> </td></tr>
            <tr><td><b>Diagnostics</b>:</td><td><a href="/alfresco/service/script/org/alfresco/repository/imap/start-workflow.get">Inspect Web Script (org/alfresco/repository/imap/start-workflow.get)</a></td></tr>
         </table>
      </div>
   </body>
</html>


I'm getting the nodeRefId for which I uploaded in the alfresco.

Please can you specify the reason where I'm doing wrong or It's need any property changes in alfresco?

I need the reply urgently.


Thanks & Regards,
Veda

Outcomes