cancel
Showing results for 
Search instead for 
Did you mean: 

Complete a pending task using REST API

sindhana
Champ in-the-making
Champ in-the-making
Hi,

I queried the pending tasks within a process using the REST call POST api/enterprise/tasks/query, which returned set of tasks. When I tried to complete the task using POST api/enterprise/task-forms/{taskId} and PUT api/enterprise/tasks/{taskId}/action/complete, I'm getting the forbbidden error (HTTP 403).

Using HTTPBasic authentication for making rest calls. Is there anyway I can call these REST services?

8 REPLIES 8

sindhana
Champ in-the-making
Champ in-the-making
I understand that we can use either one of call to complete a task. I was trying to use one at a time to test which one is working.

This is how I tested.
Using postman app (google chrome extension), I made a call with my activiti login credentials. It throwed Access forbidden error.
(OR)
Within JAVA delegate class, made the rest call. I'm getting the same error again

sindhana
Champ in-the-making
Champ in-the-making
Thanks for you reply!!

shagufta1
Champ in-the-making
Champ in-the-making
Have you passed JSON data with it? which requires for your form to complete…

shagufta1
Champ in-the-making
Champ in-the-making
Can you provide some more details like how you are posting data to the Activiti server…

Also afaik you need not to call PUT api/enterprise/tasks/{taskId}/action/complete separately to complete the task after submitting the form details with POST api/enterprise/task-forms/{taskId} call it will automatically complete the task…

sindhana
Champ in-the-making
Champ in-the-making
Yes. For the POST call this is the model {"values":{"request":"123"},"outcome":"Confirm"}. For the PUT call there is no need for json body (mentioned in Alfresco activiti documentation)

shagufta1
Champ in-the-making
Champ in-the-making
In your JSON,  "request" is the id of one of your form field right? Can you give a try without specifying the outcome…

Also PUT api/enterprise/tasks/{taskId}/action/complete is for completing the standalone task which is not associated with a process or without a task form… So in your case I think the POST call should work…

leealt
Champ in-the-making
Champ in-the-making

I am trying t do the same thing as Sindhana. I am using the POST to api/enterprise/task-forms/{taskId}. I do not have a an outcome in my json body. The user task has a form with 1 field on it with the id - "completedByInitials" and the body looks like this (from Postman) {"values":{"completedByInitials":"JDG"}}.

I am using basic auth, with the Admin credentials and impersonation with "activiti-user someone@somewher.com" and activiti-user-value-type "userEmailType". These are the same values I use to claim the task. 

Any thoughts?

sindhana
Champ in-the-making
Champ in-the-making
Thanks for replying the question.

I removed "outcome" from the POST call json body and it resolved the issue. I'm able to cancel the request now.

Thanks for the information about PUT rest call too.