Using the Workflow Management API
There are some high-level steps required to use the workflow management API effectively:
1. Set up Security
Ensure that the executing user account has Admin permissions on the K2 environment. If the code will be managing workflows, ensure that the user account has Admin rights for the workflow as well.
2. Instantiate the object
Instantiate a WorkflowManagementServer object
Instantiate the object
SourceCode.Workflow.Management.WorkflowManagementServer K2MgmtServer = new WorkflowManagementServer();
3. Create a Connection String
Build up a connection string with the SCConnectionStringBuilder object
Create a connection string
SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder builder = new SCConnectionStringBuilder();
builder.Integrated = true; //use the current user"s security credentials
builder.IsPrimaryLogin = true; //true = re-authenticate user, false = use cached security credentials
builder.Authenticate = true; //whether to authenticate the user's credentials against the security provider, usually true
builder.Host = "localhost"; //the name of the K2 server
builder.Port = 5555; //you must use port 5555 when connecting with the management API
builder.SecurityLabelName = "K2"; //this sample uses the Active Directory security provider
4. Open the Connection
Open the WorkflowManagementServer object’s connection
5. Perform tasks
Perform the required action by calling a method of the WorkflowManagementServer object
6. Clean up
You should Close the WorkflowManagementServer object’s connection when you are done executing methods.