<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Complete workflow task through REST API in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/complete-workflow-task-through-rest-api/m-p/315235#M2236</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Fetch &amp;gt; Context Document(s)
Workflow Context &amp;gt; Get open tasks
   (no parameters)
Workflow Context &amp;gt; Complete tast
    status: approved (in my test, it is the transition I want to use)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is not a REST example, but maybe it can help.&lt;/P&gt;
&lt;P&gt;Thibaud&lt;/P&gt;</description>
    <pubDate>Tue, 29 Oct 2013 19:45:13 GMT</pubDate>
    <dc:creator>ThibArg_</dc:creator>
    <dc:date>2013-10-29T19:45:13Z</dc:date>
    <item>
      <title>Complete workflow task through REST API</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/complete-workflow-task-through-rest-api/m-p/315234#M2235</link>
      <description>&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;curl -X POST -u meddev1:password --header "Content-Type:application/json+nxrequest" &lt;BR /&gt; /&amp;gt;
-H 'X-NXDocumentProperties:*'&lt;BR /&gt; /&amp;gt;
-d "{"input":"doc:/default-domain/workspaces/Math Workspace/$mediaId/$mediaItemId", "params": {"id":"Done"} }" &lt;BR /&gt; /&amp;gt;
$root/automation/Workflow.CompleteTaskOperation&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;After the above call, I get this error message:&lt;/P&gt;
&lt;P&gt;org.nuxeo.ecm.core.api.ClientException: User with id 'meddev1' cannot end this task&lt;/P&gt;
&lt;P&gt;I believe that this is failing in TaskServiceImpl.endTask&lt;/P&gt;
&lt;P&gt;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?&lt;/P&gt;
&lt;P&gt;curl -X GET -u Administrator:Administrator --header "Content-Type:application/json+nxrequest" &lt;BR /&gt; /&amp;gt;
-d "{}" &lt;BR /&gt; /&amp;gt;
$root/api/path/default-domain/workspaces/$workspace/$mediaId/$mediaItemId/@children &lt;BR /&gt; /&amp;gt;
| python -m json.tool&lt;/P&gt;
&lt;P&gt;The above command does not return any child documents.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2013 04:33:05 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/complete-workflow-task-through-rest-api/m-p/315234#M2235</guid>
      <dc:creator>mgillian_</dc:creator>
      <dc:date>2013-10-28T04:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: Complete workflow task through REST API</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/complete-workflow-task-through-rest-api/m-p/315235#M2236</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Fetch &amp;gt; Context Document(s)
Workflow Context &amp;gt; Get open tasks
   (no parameters)
Workflow Context &amp;gt; Complete tast
    status: approved (in my test, it is the transition I want to use)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is not a REST example, but maybe it can help.&lt;/P&gt;
&lt;P&gt;Thibaud&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2013 19:45:13 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/complete-workflow-task-through-rest-api/m-p/315235#M2236</guid>
      <dc:creator>ThibArg_</dc:creator>
      <dc:date>2013-10-29T19:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Complete workflow task through REST API</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/complete-workflow-task-through-rest-api/m-p/315236#M2237</link>
      <description>&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;curl -X POST -u meddev1:password --header "Content-Type:application/json+nxrequest" &lt;BR /&gt; /&amp;gt;
-d "{"input":"doc:/default-domain/workspaces/Math Workspace/$mediaId/$mediaItemId", "params": {"id":"glac_taskDone"} }" &lt;BR /&gt; /&amp;gt;
$root/automation/Context.RunOperation &lt;BR /&gt; /&amp;gt;
| python -m json.tool&lt;/P&gt;
&lt;P&gt;In addition, because my workflow transition also calls an automation chain, I verified that chain successfully executed as well.  Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2013 20:28:47 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/complete-workflow-task-through-rest-api/m-p/315236#M2237</guid>
      <dc:creator>mgillian_</dc:creator>
      <dc:date>2013-10-30T20:28:47Z</dc:date>
    </item>
  </channel>
</rss>

