Testing with C#

For simplicity, all the C# examples will use the methods in this section

References and Namespace Imports

The methods shown in this page will require that Xpertdoc.Portal.Sdk (available on Nuget) to be included as a reference in your project.

Make sure you also include the following:

using Xpertdoc.Portal.Sdk;

Setting up the Context

The following code snippet logs the user with either Windows Credentials or Forms Authentication.

private const string Username ="username";
private const string Password = "password";
private const string PortalAddress = "http://portal.xpertdoc.com/odata4/v6/";

// If we do not have a username, use our Windows Credentials (DefaultNetworkCredentials)
// Otherwise, use forms authentication (username/password)
var portalContext = string.IsNullOrEmpty(Username) ?
new PortalODataContext(new Uri(PortalAddress))
{
  Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
}
: new PortalODataContext(new Uri(PortalAddress), Username, Password);

The context can then be used to query Xpertdoc Portal, the following example will print the name of the first Template Library

var templateLibraryName  = portalContext.TemplateLibraries.FirstOrDefault();
Console.WriteLine (templateLibraryName);