Configuring the K2 REST Services for use with K2 SQL User Manager

This content applies to legacy components (such as K2 Studio and K2 for Visual Studio), legacy assemblies, legacy services or legacy functionality. If you have upgraded from K2 blackpearl 4.7 to K2 Five, these items may still be available in your environment. These legacy items may not be available in new installations of K2 Five. These legacy items may also not be available, supported, or behave as described, in future updates or versions of K2. Please see the legacy component support policy for more information about support for these components.

K2 REST services are setup to use the Active Directory User Manager by default. Use the following steps to enable K2 REST Services with K2 SQL User Manager (SQLUM):

  1. Change the security label in the <sourcecode.services> section of the WebServices web.config file to K2SQL.
    This file is located in “%PROGRAMFILES%\K2\WebServices\K2Services\”

  2. In the HostServer.SecurityLabel table of the K2 databse, set the DefaultLabel to True for the K2SQL SecurityLabelName.

  3. In your application, construct the CredentialCache for the HttpRequest header using the following code sample as an example:
    string restServiceURL = "http://[K2Server]/K2Services/Rest.svc/worklist/Items";
    string username = "[username]";
    string password = "[password]";
    //get the Worklist as a XML document
    System.Xml.Linq.XDocument document = null;

    try {
     var request = (HttpWebRequest) WebRequest.Create(restServiceURL);
     request.PreAuthenticate = true;
     CredentialCache cache = new CredentialCache();
     cache.Add(new Uri(restServiceURL), "Basic", new NetworkCredential(username, password));
     request.Credentials = cache;
     using(HttpWebResponse response = request.GetResponse() as HttpWebResponse) {
      StreamReader reader = new StreamReader(response.GetResponseStream());
      document = XDocument.Load(reader);
     }
    } catch (Exception ex) {
     Console.WriteLine(ex.Message);
    }