cancel
Showing results for 
Search instead for 
Did you mean: 

Can I start a Task with java code?

evan
Champ in-the-making
Champ in-the-making
Hi All,

    Did activiti have a web-service or interface to start up a task ? I mean I have a tomcat to run a project . activiti in another tomcat . when operator start a function on the project . in the same time .activiti will started a task .
8 REPLIES 8

frederikherema1
Star Contributor
Star Contributor
You can use the REST-API to start up a process or complete a task: http://www.activiti.org/userguide/index.html#N1196B

evan
Champ in-the-making
Champ in-the-making
Thanks for your help .It is useful for me .

evan
Champ in-the-making
Champ in-the-making
Hi Frederikheremans,
    I have read the REST-API and find out the "Execute an action" in web scripts ,but I can not understand the parameter  about  "connectorId={connectorId}&artifactId={artifactId}&actionName={artifactActionName}" where and how can I get  parameters ?

Thanks .

frederikherema1
Star Contributor
Star Contributor
Hi,

The action you are referring to is for activiti-cycle. The API's you're looking for are the ones under the Engine, Process, Repository and Management section in the userguide, eg:

Starting a process instance:

Request: POST /process-instance
{
  "processDefinitionId":"financialReport:1"
}

Completing a task:

Request: PUT /task/{taskId}/[claim|complete]
{}

evan
Champ in-the-making
Champ in-the-making
So if using the provided example process of "FinancialReportProcess", what should I place for below red color id in order to execute process.

PUT /activiti-rest/service/artifact-action?connectorId={connectorId}&artifactId={artifactId}&actionName={artifactActionName}


   <process name="FinancialReportProcess" id="[color=#0000FF]FinancialReportProcess[/color]" isExecutable="false">
      <startEvent id="[color=#8000FF]StartNoneEvent[/color]" name="[color=#FF00FF]StartNoneEvent[/color]">
         <documentation id="sid-74020069-3909-434e-81f2-fc67f4f578fd">Original Name: "" Original ID: "sid-65A1BDFB-8A62-4BB7-85A7-83375147083E"</documentation>
         <extensionElements>
           
         </extensionElements>
         <outgoing>SequenceFlow</outgoing>
      </startEvent>

To my understand, will it look like as this?
http://localhost:8080/activiti-rest/service/artifact-action?connectorId={FinancialReportProcess}&artifactId={StartNoneEvent}&actionName={StartNoneEvent}

frederikherema1
Star Contributor
Star Contributor
To start the process "FinancialReportProcess", you should call the folowing REST:


POST /process-instance
{
  "processDefinitionId":"FinancialReportProcess:1"
}

and this will return something like the following JSON, indicating the process was started:

{
  "id": "217",
  "processDefinitionId": "financialReport:1",
  "activityNames": ["firstTaskInProcess"],
  "ended": false
}


Please not that the process-definition ID mentioned above assumes there is only one version of the financial process deployed. To get all deployed definition to be sure you use the correct processDefinitionId, you can use:

GET /process-definitions?start=0&size=100

evan
Champ in-the-making
Champ in-the-making
Hi Frederikheremans ,

     Thanks for your reply, I have read online document and try to create a path to call webscript, my path is :
http://localhost:8080/activiti-rest/service/process-instance?processDefinitionId=FinancialReportProc...
I can not get anything yet . return is "File not found". can you help me to create the true path?


Thanks All.

evan
Champ in-the-making
Champ in-the-making
Hi All,

    Who can help me how to create the real path? I have try many time and return result is same message : " File not found " .

Thanks all.