I added the following new method to org.activiti.rest.service.api.runtime.task.TaskResouce to enable new task creation via POST. Id will be determined by Activiti.
@RequestMapping(value="/runtime/task", method = RequestMethod.POST, produces="application/json")
public TaskResponse createTask(
@RequestBody TaskRequest taskRequest, HttpServletRequest request) {
if (taskRequest == null) {
throw new ActivitiException("A request body was expected when updating the task.");
}
Task task = new org.activiti.engine.impl.persistence.entity.TaskEntity();
// Populate the task properties based on the request
populateTaskFromRequest(task, taskRequest);
if (task.getId() != null) {
throw new ActivitiIllegalArgumentException("Cannot create task with a specified id");
}
// Save the task and fetch again, it's possible that an assignment-listener has updated
// fields after it was saved so we can't use the in-memory task
taskService.saveTask(task);
task = taskService.createTaskQuery().taskId(task.getId()).singleResult();
return restResponseFactory.createTaskResponse(task);
}
Still would appreciate confirmation that this is not located elsewhere and I have somehow missed it in my searches. Also would like to know if this is an intentional omission from the REST services?