error getting from starting business process through Rest API

844 views
Skip to first unread message

suresh.t...@gmail.com

unread,
Jan 7, 2014, 7:11:15 AM1/7/14
to camunda-...@googlegroups.com
Hi,
I want start particular process definition through Rest API. I used http://localhost:8080/engine-rest/process-instance API call with POST and i am passingprocess definition id with below code:
hp.setEntity(new StringEntity("{\"processDefinitionKey\":\"service1\"}", "UTF-8"));

I am getting below error:
SEVERE: Failed executing POST /process-instance
org.jboss.resteasy.spi.UnsupportedMediaTypeException: Cannot consume content type
at org.jboss.resteasy.core.registry.Segment.match(Segment.java:117)
at org.jboss.resteasy.core.registry.SimpleSegment.matchSimple(SimpleSegment.java:33)
at org.jboss.resteasy.core.registry.RootSegment.matchChildren(RootSegment.java:327)
at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:374)
at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:367)
at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker
Please provide exact API and paramters for starting business process.

regards,
suresh

Daniel Meyer

unread,
Jan 7, 2014, 9:58:03 AM1/7/14
to camunda-...@googlegroups.com, suresh.t...@gmail.com
Hi Suresh,

could you please provide some more information about your usage context? I assume that you are using some REST client from Java to do the post? Which libraries are you using? Is your JSON transformed correctly?

Cheers,
Daniel 

thorben....@student.hpi.uni-potsdam.de

unread,
Jan 7, 2014, 10:12:47 AM1/7/14
to camunda-...@googlegroups.com, suresh.t...@gmail.com
Hi Suresh,

are you setting the content type header of your request to "application/json"?

Cheers,
Thorben

tom...@gmail.com

unread,
Jan 7, 2014, 7:37:57 PM1/7/14
to camunda-...@googlegroups.com, suresh.t...@gmail.com
As a new user I use a rest client plugin.
Execute a GET request e.g. http://localhost:8080/engine-rest/engine/default/process-definition
Using the ID from above
Execute a POST request e.g. http://localhost:8080/engine-rest/engine/default/process-definition/<key>:<version>:<deployment id>/start

Ensure the content type is set, as this appears to be the error. Content-Type is application/json

Body should be empty or {}

Regards
Tom

suresh.t...@gmail.com

unread,
Jan 8, 2014, 12:06:48 AM1/8/14
to camunda-...@googlegroups.com, suresh.t...@gmail.com
Hi Daniel,
Now i am not getting error by setting content type as application/json but my process is not starting with http://localhost:8080/engine-rest/process-instance .

Please provide correct Rest API for starting business process.
I am using HTTPClient API and code given below.
DefaultHttpClient dhc = new DefaultHttpClient();

dhc.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM), new UsernamePasswordCredentials("demo", "demo"));

HttpPost hp = new HttpPost("http://localhost:8080/engine-rest/process-instance");

AuthCache authCache = new BasicAuthCache();
// Generate BASIC scheme object and add it to the local auth cache
BasicScheme basicAuth = new BasicScheme();
authCache.put(new HttpHost("localhost", 8080, "http"), basicAuth);

// Add AuthCache to the execution context
BasicHttpContext localcontext = new BasicHttpContext();
localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);

HttpResponse processResponse;

try {
hp.setHeader("Content-type", "application/json");
hp.setEntity(new StringEntity("{\"processDefinitionKey\":\"service1\"}", "UTF-8"));
processResponse = dhc.execute(hp,localcontext);
BufferedReader br = new BufferedReader(
new InputStreamReader((processResponse.getEntity().getContent())));

String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
}
dhc.getConnectionManager().shutdown();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
regards,
suresh

suresh.t...@gmail.com

unread,
Jan 8, 2014, 4:27:57 AM1/8/14
to camunda-...@googlegroups.com, suresh.t...@gmail.com
Hi Tom,
I tried with executing http://localhost:8080/engine-rest/process-definition/myProcess/start for starting process but i am getting below error.
{"type":"RestException","message":"Cannot instantiate process definition myProcess: no deployed process definition found with id 'myProcess'"}

myProcess process definition is exist in my BP Engine.Please let me know the solutions for this.

regards,
suresh
On Tuesday, 7 January 2014 13:11:15 UTC+1, suresh.t...@gmail.com wrote:

Christian Lipphardt

unread,
Jan 9, 2014, 4:27:37 AM1/9/14
to camunda-...@googlegroups.com, suresh.t...@gmail.com
Hi Suresh,

you try to start a process instance from your process definition by using the key of the process definition (which is the attribute id in the bpmn xml).
You have to look up the id of your process definition by using http://localhost:8080/engine-rest/process-definition and search through the result what the id is.

Starting a process instance by key will be available with the next alpha release, see https://app.camunda.com/jira/browse/CAM-1505

Cheers
Christian
Reply all
Reply to author
Forward
0 new messages