cancel
Showing results for 
Search instead for 
Did you mean: 

Error while starting deployed Process using REST API

unm_activiti
Champ in-the-making
Champ in-the-making
I am new to Activiti and trying to start a process using the REST API. I have created a simple process using the explorer and modeller and have been able to deploy this process.
Using the REST API I can see the process definition of this process.
But when I try to start this process using the POST method specifying the processDefinitionId, I get an error "415 Unsupported Media Type".
The POST API I am using is
POST /activiti-explorer/service/runtime/process-instances
with body as  { "processDefinitionId":"BPM_EntityType_1:1:1290" }
Please help.
10 REPLIES 10

frederikherema1
Star Contributor
Star Contributor
We have unit-tests for this (org.activiti.rest.api.runtime.ProcessInstanceCollectionResourceTest.testStartProcess). Double-check the JSON you're sending is valid and the "processDefinitionId" is spelled correctly. What framework/tech/app are you using to do the call?

creidef
Champ in-the-making
Champ in-the-making
Hi,

I have exactly the same issue. I'm using activiti 5.14.

I created a simple process and after a successfully deployment with the activiti explorer I can run the process in activiti explorer.

When I'm using the REST API to get the process definition it seems everything is ok. Then I tried: POST http://localhost:8080/activiti-rest/service/runtime/process-instances

with body: {"processDefinitionId":"verySimpleProcess:1:7164"}

I receive the same error 415 unsupported media type.

I used RESTClient plugin in firefox and I also wrote a simple program. The logs only said:

127.0.0.1 - - [24/Nov/2013:01:55:15 +0000] "POST /activiti-rest/service/runtime/process-instances HTTP/1.1" 415 69

trademak
Star Contributor
Star Contributor
Could you check if you have set an header Content-type:application/json ?

Best regards,

creidef
Champ in-the-making
Champ in-the-making
Yes, I set rep.setMediaType(MediaType.APPLICATION_JSON);

my code looks like this:

<code lang="java">
String uri = REST_URI + "/runtime/process-instances";
JSONStringer jsRequest = new JSONStringer();
jsRequest.object();
jsRequest.key("processDefinitionId").value(processDefinitionId);
jsRequest.endObject();
Representation rep = new JsonRepresentation(jsRequest);
logger.info("json string: " + rep.getText());
rep.setMediaType(MediaType.APPLICATION_JSON);
JSONObject jsObj = new JSONObject(getClientResource(uri).post(rep).getText());
logger.info("Returning processId " + jsObj.getString("id"));
</code>

creidef
Champ in-the-making
Champ in-the-making
now it's working … I set up a new activiti database without demo data and deployed the process via explorer again and I can start the process with the previous posted code … next step is to start the process with variables.

🙂

b_schnarr
Champ in-the-making
Champ in-the-making
I can confirm this. The problem only appears with demo process definitions.

trademak
Star Contributor
Star Contributor
Is there a stacktrace in the REST app log?

Best regards,

b_schnarr
Champ in-the-making
Champ in-the-making
Maybe the solution is described here: http://forums.activiti.org/content/rest-query-415

I could fix the Problem with removing a space caracter in the Rest Body. After That, the mentioned queries worked Fine.

You have space character too in

{ "processDefinitionId":"BPM_EntityType_1:1:1290" }

You should try with

{"processDefinitionId":"BPM_EntityType_1:1:1290"}

That should work

conics
Champ in-the-making
Champ in-the-making
I'm stuck with the same problem, trying to activate deployed process definition. I'm using Activiti 5.15 and Mozilla RESTClient add-on. When I pass parameter "processDefinitionId":"test-rest:1:4803" in the POST request, I get attached exception and execution never gets into ProcessInstanceCollectionResource class, which handles process instance resource.  However, if no parameters are specified in the POST, then execution does gets in ProcessInstanceCollectionResource.createProcessInstance(ProcessInstanceCreateRequest request) method, with request=null, which causes 500 error. Hope this sheds more light on the problem.

Error from the log file:

Feb 18, 2014 3:41:01 PM org.restlet.engine.log.LogFilter afterHandle
INFO: 2014-02-18 15:41:01 127.0.0.1 afdasf 127.0.0.1 8080 POST /activiti-rest2/service/runtime/process-instances - 415 - 40 412 http://localhost:8080 Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0 -
Feb 18, 2014 3:49:50 PM org.restlet.ext.jackson.JacksonRepresentation getObject
WARNING: Unable to parse the object with Jackson.
org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [simple type, class org.activiti.rest.service.api.runtime.process.ProcessInstanceCreateRequest] from JSON String; no single-String constructor/factory method
at org.codehaus.jackson.map.deser.std.StdValueInstantiator._createFromStringFallbacks(StdValueInstantiator.java:379)
at org.codehaus.jackson.map.deser.std.StdValueInstantiator.createFromString(StdValueInstantiator.java:268)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromString(BeanDeserializer.java:765)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:585)
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2732)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1909)
at org.restlet.ext.jackson.JacksonRepresentation.getObject(JacksonRepresentation.java:139)
at org.restlet.ext.jackson.JacksonConverter.toObject(JacksonConverter.java:218)
at org.restlet.service.ConverterService.toObject(ConverterService.java:161)
at org.restlet.resource.UniformResource.toObject(UniformResource.java:647)
at org.restlet.resource.ServerResource.doHandle(ServerResource.java:434)
at org.restlet.resource.ServerResource.post(ServerResource.java:1114)
at org.restlet.resource.ServerResource.doHandle(ServerResource.java:533)
at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:590)
at org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:302)
at org.restlet.resource.ServerResource.handle(ServerResource.java:849)
at org.restlet.resource.Finder.handle(Finder.java:513)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Router.doHandle(Router.java:500)
at org.restlet.routing.Router.handle(Router.java:740)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:155)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.engine.ChainHelper.handle(ChainHelper.java:114)
at org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:75)
at org.restlet.Application.handle(Application.java:391)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Router.doHandle(Router.java:500)
at org.restlet.routing.Router.handle(Router.java:740)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.routing.Router.doHandle(Router.java:500)
at org.restlet.routing.Router.handle(Router.java:740)
at org.restlet.routing.Filter.doHandle(Filter.java:159)
at org.restlet.routing.Filter.handle(Filter.java:206)
at org.restlet.engine.ChainHelper.handle(ChainHelper.java:114)
at org.restlet.Component.handle(Component.java:391)
at org.restlet.Server.handle(Server.java:491)
at org.restlet.engine.ServerHelper.handle(ServerHelper.java:74)
at org.restlet.engine.http.HttpServerHelper.handle(HttpServerHelper.java:153)
at org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:1031)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)