Workflow REST API Code Samples

These samples demonstrate common uses of the Workflow REST API.

Sample Projects

Sample Project
You can use the following sample project on Github for examples of common uses of the Workflow Client API. K2Documentation.Samples.WorkflowRuntime.WorkflowRESTAPI. The sample project is provided for demonstration purposes only. It is not supported by K2 product support and is not intended to be used as-is in production environments.

Code Samples

The topics listed in the table below contain code samples that demonstrate specific uses of the Workflow REST API. Note that the samples use basic authorization for simplicity. If you need to use OAuth instead, see the topic Authentication with the Workflow REST API.

Topic Description
C#: Authentication with the Workflow REST API Various ways to pass authentication credentials to the Workflow REST API (C# Sample).
C#: Workflow REST API: Retrieve available workflows How to return a list of workflows that the authenticated user is allowed to start (C# Sample).
C#: Workflow REST API: Starting a workflow How to start a new workflow instance (C# Sample).
C#: Workflow REST API: Retrieve Task List How to retrieve the worklist/task list for the authenticated user (C# Sample).
C#: Workflow REST API: Open and Complete Task How to open and complete a workflow task/task list item (C# Sample).
C#: Workflow REST API: Task Operations How to perform common 'system' operations on workflow tasks, such as sleeping, waking, redirecting, allocating (opening) and releasing tasks
C#: How to use the "Wait for External System" option How to use the 'Wait for External System' option on a SmartObject step in a workflow to implement a asynchronous server task.
JS: Workflow REST API: Retrieve available workflows How to return a list of workflows that the authenticated user is allowed to start (JavaScript sample)
JS: Workflow REST API: Retrieve workflow metadata How to return the definition of a workflow instance (JavaScript sample).
JS: Workflow REST API: Starting a workflow How to start a new workflow instance (JavaScript sample).
JS: Workflow REST API: Retrieve Task List How to retrieve the worklist/task list for the authenticated user (JavaScript sample).
JS: Workflow REST API: Open and Complete Task How to open and complete a workflow task/task list item (JavaScript sample).
Workflow REST API: Item References How to format Item Reference data (in XML or JSON)