AnsweredAssumed Answered

How to start process instance using REST API ?

Question asked by amp on Oct 10, 2013
Latest reply on Oct 16, 2013 by martin.grofcik
I have created following class.
I m getting error forbidden and also i tried with processdefinition key.
plz  help me. I am new to REST API.



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;

public class Rest {

   public static void main(String[] args) {
     try {

      DefaultHttpClient httpclient = new DefaultHttpClient();
      httpclient.getCredentialsProvider().setCredentials(
              new AuthScope("localhost", 8080),
              new UsernamePasswordCredentials("kermit", "kermit"));
      HttpPost hp = new HttpPost("http://localhost:8080/activiti-rest/service/process-instance");
      hp.setEntity(new StringEntity("{\"processDefinitionId\":\"reviewSaledLead\"}", "UTF-8"));
      HttpResponse processResponse = httpclient.execute(hp);
      System.out.println(IOUtils.toString(processResponse.getEntity().getContent()));
      httpclient.getConnectionManager().shutdown();   
     }
     catch(Exception ae)
     {
       
     }
     }
}

Outcomes