I'm trying to start a process as chapter 8 of the book Activiti in Action is my code so and returns the following error:
restAPITest(org.bpmnwithactiviti.chapter8.rest.RestTest) Time elapsed: 0.98 sec <<< ERROR! Bad Request (400) - Bad Request at org.restlet.resource.ClientResource.handle(ClientResource.java:858) at org.restlet.resource.ClientResource.post(ClientResource.java:1197) at org.bpmnwithactiviti.chapter8.rest.ActivitiRestClient.startVacationRequestProcess(ActivitiRestClient.java:56) at org.bpmnwithactiviti.chapter8.rest.RestTest.restAPITest(RestTest.java:15) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110) at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175) at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
My code:
public static String startVacationRequestProcess(String processDefinitionId) throws Exception { String uri = "http://localhost:8080/activiti-rest/service/runtime/process-instances"; JSONStringer jsRequest = new JSONStringer(); jsRequest.object(); jsRequest.key("processDefinitionId").value(processDefinitionId); jsRequest.key("employeeName").value("Miss Piggy"); jsRequest.key("numberOfDays").value("10"); jsRequest.key("startDate").value("2011-01-01"); jsRequest.key("returnDate").value("2011-01-11"); jsRequest.key("vacationMotivation").value("tired"); jsRequest.endObject(); Representation rep = new JsonRepresentation(jsRequest); JSONObject jsObj = new JSONObject(getClientResource(uri).post(rep).getText()); logger.info("Returning processId " + jsObj.getString("id")); return jsObj.getString("id"); }