cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot complete a task using REST API (Activiti 5.14)

obdurate
Champ in-the-making
Champ in-the-making
I have created a process definition in Activiti (5.14) which is made up of a mixture of user and service tasks.  I have created two versions, in one version the user tasks have forms so they can be run in Activiti Explorer.  In the second version the user tasks do not have forms so everything needs to be done programmatically.

I am able to unit test both process definitions using Eclipse with no problems.  I can start the process instance, set process variables, get tasks, complete tasks, etc.  All of this is done using Java calls, none of it uses REST. I can also start a process instance (with forms) and run through it using Activiti Explorer.

Using REST I am able to start a process instance and get tasks; however, I cannot complete the tasks. I have tried to complete tasks with and without forms and I keep running into the same issue.  I am making REST calls using the Advanced REST client app in Chrome.  All calls have the Content-Type set to application/json in the header. Below are my calls and responses the the process-instance without forms in the user task.

Post to http://localhost:8080/activiti-rest/service/runtime/process-instances
Payload:
{
    "processDefinitionKey":"AddSquaresRestPOC",
     "variables": [
        {
        "name": "numbertosquare",
        "value": "4"
        }
    ]
}

Response:
{
id: "508"
url: "http://localhost:8080/activiti-rest/service/runtime/process-instances/508"
businessKey: null
suspended: false
processDefinitionId: "AddSquaresRestPOC:1:604"
processDefinitionUrl: "http://localhost:8080/activiti-rest/service/repository/process-definitions/AddSquaresRestPOC%3A1%3A6..."
activityId: "usertask1"
variables: [0]
}

Post to http://localhost:8080/activiti-rest/service/query/tasks
Payload:
{
    "executionId":"508"
}
Response:
{
data: [1]
0:  {
id: "520"
url: "http://localhost:8080/activiti-rest/service/runtime/tasks/520"
owner: null
assignee: "turner"
delegationState: null
name: "Enter First Number"
description: null
createTime: "2014-02-26T20:49:39.132+0000"
dueDate: null
priority: 50
suspended: false
taskDefinitionKey: "usertask1"
parentTaskId: null
parentTaskUrl: null
executionId: "508"
executionUrl: "http://localhost:8080/activiti-rest/service/runtime/executions/508"
processInstanceId: "508"
processInstanceUrl: "http://localhost:8080/activiti-rest/service/runtime/process-instances/508"
processDefinitionId: "AddSquaresRestPOC:1:604"
processDefinitionUrl: "http://localhost:8080/activiti-rest/service/repository/process-definitions/AddSquaresRestPOC%3A1%3A6..."
variables: [0]
}
total: 1
start: 0
sort: "id"
order: "asc"
size: 1
}

Get to http://localhost:8080/activiti-rest/service/task/520
Response:
{
assignee: "turner"
createTime: "2014-02-26T15:49:39EST"
delegationState: null
description: null
dueDate: null
executionId: "508"
id: "520"
name: "Enter First Number"
owner: null
parentTaskId: null
priority: 50
processDefinitionId: "AddSquaresRestPOC:1:604"
processInstanceId: "508"
taskDefinitionKey: "usertask1"
formResourceKey: null
subTaskList: [0]
identityLinkList: [1]
0:  {
type: "assignee"
userId: "turner"
groupId: null
}
attachmentList: [0]
}

Put to http://localhost:8080/activiti-rest/service/task/520/complete
Response:
{
errorMessage: "Not Found"
statusCode: 404
}

Post to http://localhost:8080/activiti-rest/service/runtime/tasks/520
Payload:
{
    "action":"complete"
}
Response:
{
errorMessage: "Not Found"
statusCode: 404
}

I have attached catalina.out to this message as catalina.txt.  Any help would be appreciated.
11 REPLIES 11

vasile_dirla
Star Contributor
Star Contributor
415 => Unsupported Media Type   ( server doesn’t support that content type)

Did you send 'Accept' and 'Content-Type' headers with your request?
'Accept': 'application/json' 
'Content-Type': 'application/json'

Much Thanks vasile!
I did it successfully when I passed the object TaskActionRequest directlly.
post request object directlly.
No need to  "objectMapper.writeValueAsString".