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

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 “[Program Files (x86)]\K2 blackpearl\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);
    }

K2 blackpearl Developers Reference4.7
Video Links Learn Support
No videos found for this article
K2 on YouTube
No Additional links found for this article
No self-learning content for this article
Try some scenarios...
No relevant support links available for this article