cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow REST Api and Workflow Content

conte73
Champ in-the-making
Champ in-the-making
Hi,
I am developing a REST client to Alfresco workflow. I already access task instance details trough:
http://wiki.alfresco.com/wiki/Workflow_REST_API#Get_Task_Instance
Now i want to get the content associated to the workflow instance.
Is it possible? Can someone point me to the api (mabe CMIS?) that i can use?

Thanks in advance.
Gabriele
2 REPLIES 2

gavinc
Champ in-the-making
Champ in-the-making
First of all you'll need to find the 'package' nodeRef for the workflow instance by using the http://wiki.alfresco.com/wiki/Workflow_REST_API#Get_Workflow_Instance API.

Once you have that you can use the Alfresco repository REST APIs or the CMIS REST APIs to retrieve the children of the nodeRef.

conte73
Champ in-the-making
Champ in-the-making
Thank you: i did so and it worked.
more detaily given the answer to the GetTaskInstances  call

{
   "data":
   [
      {
         "id": "jbpm$2",
          …        
,
         "workflowInstance":
         {
             "id": "jbpm$1",
             ….
             "context": "workspace:\/\/SpacesStore\/e4a4902c-562d-4451-8148-91f6d763bc25",
             "package": "workspace:\/\/SpacesStore\/20329587-3d2f-4823-814a-fdf26628d5f0",
             …
        }     
   ]
}

I get the package element from "workflowInstance" and then i call the cmis api http://wiki.alfresco.com/wiki/CMIS_Web_Scripts_Reference#Get_Folder_Children_.28getChildren.29:

/service/cmis/s/SpacesStore/i/20329587-3d2f-4823-814a-fdf26628d5f0/children
The answer is an xml where i can find the url for downloading the content:

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app"
   xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/"
   xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/" xmlns:alf="http://www.alfresco.org"
   xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
        …
        <entry>
                …
                <content type="application/octet-stream"
                       src="http://localhost:9090/alfresco/service/cmis/s/workspace:SpacesStore/i/78e7f974-a0df-46fe-923f-8de574..." />
                …
        </entry>
</feed>