Complete workflow task through REST API

I have seen multiple references on how to programmatically complete a task, such as using Workflow.CompleteTaskOperation. However, I can't seem to find the correct REST call. Here's the REST endpoint that I am attempting to use:

curl -X POST -u meddev1:password –header “Content-Type:application/json+nxrequest” \

-H 'X-NXDocumentProperties:*'\
-d "{\"input\":\"doc:/default-domain/workspaces/Math Workspace/$mediaId/$mediaItemId\", \"params\": {\"id\":\"Done\"} }" \

where $mediaId is a documents name, and $mediaItemId is a child document. The child document is in a workflow, and I want to mark it complete. “id” is the name of the workflow transition that I wish to execute, and meddev1:password is the user that is currently assigned the task.

After the above call, I get this error message:

org.nuxeo.ecm.core.api.ClientException: User with id 'meddev1' cannot end this task

I believe that this is failing in TaskServiceImpl.endTask

I'm assuming that I have not correctly specified the document, because Workflow.CompleteTaskOperation is looking for a TaskDocument. How do I retrieve the task document?

curl -X GET -u Administrator:Administrator –header “Content-Type:application/json+nxrequest” \

-d "{}" \
$root/api/path/default-domain/workspaces/$workspace/$mediaId/$mediaItemId/@children \
| python -m json.tool

The above command does not return any child documents.

0 votes

2 answers




You are right: CompleteTaskOperation expects a Task Document, while here it receives a “regular” document in input. I think there is a way to get the TaskDoc related to the current document: Context.GetOpenTasks operation returns a list of the open taks on current document. Here is what I did in a quick test, which worked in an automation chain:

Fetch > Context Document(s)
Workflow Context > Get open tasks
   (no parameters)
Workflow Context > Complete tast
    status: approved (in my test, it is the transition I want to use)

This is not a REST example, but maybe it can help.


1 votes

I just confirmed that your workflow suggestion worked for me. I created an Automation Chain of the above steps and executed that chain via this REST call:

curl -X POST -u meddev1:password –header “Content-Type:application/json+nxrequest” \

-d "{\"input\":\"doc:/default-domain/workspaces/Math Workspace/$mediaId/$mediaItemId\", \"params\": {\"id\":\"glac_taskDone\"} }" \
$root/automation/Context.RunOperation \
| python -m json.tool

In addition, because my workflow transition also calls an automation chain, I verified that chain successfully executed as well. Thanks!

0 votes