Start an Activiti Process via Rest Script in CrafterCMS

Activiti is a powerful open source workflow engine built by Alfresco.  Incorporating a workflow engine into your customer and employee facing sites and portals is an excellent solution for automating complex workflows that cross system boundaries while providing the user with a simple to use, contextual user experience.   Working for a bank or an insurance company and need to workflow contracts with customers?  No problem. CrafterCMS (an open source Java based CMS) paired with Alfresco is a perfect solution.  It’s customer friendly, highly scalable and about as powerful as enterprise technology gets!

In this blog, I’ll demonstrate the most straightforward example of a CrafterCMS REST service being used to start an Activiti Process.


  • You have Activiti ( installed
    The authentication and process are hard coded to simplify the example

Step 1: Create a REST Controller

    • Under Scripts/rest right click and click create controller
      • Enter start-process.get as the controller name
    • Add the following code to the controller. This code assumes Activiti is deployed into the same container as Crafter Engine.
    def http = new HTTPBuilder("http://localhost:8080")
    def user = "kermit"
    def password = "kermit"
    def authPair = user + ":" + password
    def authEncoded = authPair.bytes.encodeBase64().toString()
    http.setHeaders([Authorization: "Basic "+authEncoded])
    def ret = null

    http.request( Method.POST ) {

          uri.path = "/activiti-rest/service/runtime/process-instances"

    // uri.path = "/activiti-app/api/enterprise/process-instances" requestContentType = ContentType.JSON body = [ processDefinitionKey: "vacationRequest", variables:[ [name:"employeeName", value: "Russ"], [name:"numberOfDays", value: "5"],[name:"startDate", value:"10-08-2015 11:11"],[name:"vacationMotivation", value: "rest"] ]] response.success = { resp, reader -> ret = reader } } return ret

Step 2: Execute the Service

Step 3: Verify that a new process instance has been started

Share This Article :

Russ Danner

Russ Danner

Russ Danner is VP Products at CrafterCMS and is responsible for product management, product development and support, and client and partner success. Russ brings over 20 years of software architecture, design, and implementation experience. Prior to CrafterCMS, Russ was Web Experience Management Practice Director at Rivet Logic and project lead for the open source CrafterCMS project.