No ratings

Starting a Process Instance using REST and Powershell


Starting a Process Instance using REST and Powershell

This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.


The following article explains how to use the REST service to start a process instance:


However, in some scenarios you will need to populate a datafield before starting the instance.

Before You Begin

Before you begin you will need the following:


  • A process that you would like to start
  • A Datafield to populate
  • The K2 Services URL.

How-to Steps

Please find the Powershell Script below:



$k2server = "K2_BASE_ADDRESS";     #e.g.
$k2project = "K2_PROJECT";
$k2workflow = "K2_PROCESS";

function executeRequest() {
$apiUrl = getApiUrl
$body = getContentXml
$result = Invoke-RestMethod -UseDefaultCredentials -Method POST -Uri $apiUrl -Body $body -ContentType 'application/xml'

function getApiUrl() {
return "$($k2server)/k2services/REST.svc/Process/Instances/StartInstance";

function getContentXml() {


return "<?xml version='1.0' encoding='utf-8'?>" +
"<w:ProcessInstance xmlns:w='' xmlns:p=''" +
" FullName='$($k2project)\$($k2workflow)'>" +
"<p:DataField Name='MyProcessDataField'>$($filename)</p:DataField>" +




All values highligted in YELLOW need to be updated to reflect the values on your K2 Server.
Labels: (3)
Version history
Last update:
‎03-16-2022 02:16 AM
Updated by: