Level of Difficulty: Beginner – Senior.

UiPath has written an activity (UiPath.K2.Activities) that starts a K2 workflow. It seems quite simple at first; the only input properties that it expects are the service URL, username, password and workflow ID. It was ideal for what I was trying to achieve, until it wouldn’t load my workflows from the Service URL. My credentials were definitely correct as they worked with the API, so it had to be the Service URL. I tried multiple different permutations with no success before deciding to pivot to the API instead. So I’m sharing my workaround with you in case you are facing the same challenges I did.
What do we need to do to start a K2 workflow from UiPath?
All of the information that you need to get the HTTP Request working in UiPath can be obtained from Swagger, if it is available to you. To compile your Swagger URL, you’ll need to get your base K2 address and append /api/workflow/v1/swagger/index to it:
https://k2.<organisation>.com/api/workflow/v1/swagger/index
If there are multiple versions of the API you’re working with, substitute v1 with the latest version. You will need to obtain the following in order to make the HTTP Request:
- The request URL (including the workflow ID)
- The request body, which might differ slightly from mine
- Authorised username and password
Getting Started
First thing first – let’s create a template text file that contains the body that we will be using for the HTTP Request:

Now, create a new UiPath project/sequence and make sure you install the UiPath.WebAPI.Activities package so that you are able to make HTTP requests:

Let’s put the sequence together using the following steps:
- Read the Template text file
- Replace the placeholder text with the actual values
- Compose the HTTP Request
- Print the status code
The sequence should look something like this:

Now let’s take a closer look at each step.
Read the Template text file
The template text file is stored in the same directory as the UiPath solution and is named ‘New Workflow Template.txt’:

Replace placeholder text with values
In this scenario, the text file contains the template text to be used as the request body to start the K2 workflow. The placeholders in this case are ‘<title>’ and ‘<value>’. These can be replaced using the string replace function to replace the placeholders with the actual values that should be sent through to start the workflow:

Compose the HTTP Request
The most important part of getting an HTTP Request to work is making sure that the properties are correct. We need to set the following properties:
- AcceptFormat = JSON
- EndPoint = URL (the workflow API endpoint/URL, with the ID in the URL)
- Method = POST
- Body = NewWorkflowTemplate (the variable that stores the request body text)
- BodyFormat = “application/json”
- Password = Password (variable storing password – credentials used to auth on Swagger)
- Username = Username (variable storing username – credentials used to auth on Swagger)
- Headers = {Accept, In, String, “application/json”; Content-Type, In, String, “application/json”}:

The output parameters may be set as well. In order to display the status code, it would need to be set to a variable. The properties of the HTTP request should be as follows:

If you’d like to speed things up a little and change the solution presented in this post to work for your own use case, feel free to fork this GitHub repository and make the changes applicable to your use case. If you get stuck, please feel free to reach out or leave a comment below.