cancel
Showing results for 
Search instead for 
Did you mean: 

REST api sample request to create task

rohitagrawal
Champ on-the-rise
Champ on-the-rise
as it's not available in documentation
16 REPLIES 16

skidvd
Champ in-the-making
Champ in-the-making
I agree that POST /runtime/tasks exists.  However, it will not handle the creation of a new task (at least not in 5.17 version).  As I mentioned earlier in this thread, the POST call is expecting an action in the payload, so [posting with a new task payload only] results in a 400 Bad Request response. From looking at the org.activiti.rest.service.api.runtime.task.TaskResource source, this method only handles ACTION_COMPLETE, ACTION_CLAIM, ACTION_DELEGATE and ACTION_RESOLVE. Therefore, I conclude that the POST variant is not correct for creating a new task.

jbarrez
Star Contributor
Star Contributor
That's because you are looking at the wrong class: TaskCollectionResource is the one you need …

gelito
Champ in-the-making
Champ in-the-making
I was trying using REST to create new task but I confirm it DOESN'T work for me as well. Could you confirm it's possible and provide sample request here?

trademak
Star Contributor
Star Contributor
Of course it's possible and we have a user guide that documents each REST API service. So let us know what is not working with a description what you are trying to do.

Best regards,

alxbxbx
Champ in-the-making
Champ in-the-making
I'm trying to start new process instance via REST API.
POST request
http://localhost:8080/activiti-rest/service/runtime/process-instances

JSON parameters
{
   "processDefinitionId":"myProcess:1:43",
   "businessKey":"myProcess"

}

And i keep getting 400 response:
{
    "message": "Bad request",
    "exception": "Required request body content is missing: org.springframework.web.method.HandlerMethod$HandlerMethodParameter@21d082af"
}

Can someone please tell me what am i doing wrong?
I guess i miss some parameter, but every task in my process doesn't have any parameters.

manusoftar
Champ in-the-making
Champ in-the-making
For as long as i know, you should use a JSON object with the following syntaxis as your requestbody.

data : {    "processDefinitionId" : "myProcess:1:43",
               "bussinesKey" : "myProcess"
}

Take special attention to the DATA thing, you store your JSON object on the data param so that activiti engine can recognize it.

Hope it works for you as it worked for me. Good luck!

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Aleksadar,

The best way to get familiar with any activiti topic is to:
download activiti source.
search for jUnit tests (your problem could be covered in org/activiti/rest/service/api/runtime package)

Regards
Martin