How to Authenticate With Sage Intacct SDK for .NET

Sage Intacct has released an official software development toolkit (SDK) in April 2017. This release was just in time, as the Intacct Web Services Test tool is being phased out as Google ends support for Chrome Apps.

On the official SDK page, as of writing this post, there is actually only a single example.

As I explore the SDK, I will be providing some working examples that I have found useful. To start with let’s take a look at basic authentication with Intacct.

To get this going, let’s open a new console application using the 4.5.2  or higher framework, I named my application “AuthIntacct”.

Next, we will need to navigate to the toolbar Tools -> Nuget Package Manager -> Package Manager Console

and run the command

PM> Install-Package Intacct.SDK

After you get a success as shown:

Then we can build our program. I have setup a Configuration class to store my passwords for simplicity in this example. These are not real credentials. You will need to have a working account to run these examples either in a development instance or production.

using System;
using System.Threading.Tasks;
using System.Web;
using Intacct.Sdk;
using Intacct.Sdk.Xml;
using Intacct.Sdk.Functions.Common;

namespace AuthIntacct
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                SdkConfig config = new SdkConfig()
                {
                    SenderId = Configuration.SenderId,
                    SenderPassword = Configuration.SenderPassword,
                    CompanyId = Configuration.CompanyId,
                    UserId = Configuration.UserId,
                    UserPassword = Configuration.UserPassword,
                    EndpointUrl = Configuration.EndpointUrl,
                    DtdVersion = Configuration.DtdVersion,
                    Encoding = "iso-8859-1"
                };

                IntacctClient client = new IntacctClient(config);

                if (client.SessionCreds.SessionId != "")
                    Console.Write("Our SessionID is: " + client.SessionCreds.SessionId);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception caught: " + ex.Message);
            }
        }
    }
    public class Configuration
    {
        public static string SenderId = "fakeCompany";
        public static string SenderPassword = "123password";
        public static string CompanyId = "fakeCompany";
        public static string UserId = "fakeCompany_xml";
        public static string UserPassword = HttpUtility.HtmlEncode("123456789");
        public static string EndpointUrl = "https://api.intacct.com/ia/xml/xmlgw.phtml";
        public static string DtdVersion = "3.0";
    }
}

You may notice that I have provided a few extra parameters for the SdkConfig. That is because in the initial setup the EndpointUrl is not configured, the XML Encoding also is omitted. In my experience, with Intacct not specifying the Encoding can cause a headache that can easily be avoided had you specified this to start.

Additionally, it is important to specify your DtdVersion. Intacct supports both version 3.0 and 2.1, I would default to 3.0 as this is the newer flavor. Forgetting about 2.0 altogether though, will handicap the abilities of your code.

I also provided for the EndpointUrl. Setting this up keeps it in my head when working and also allows me to switch between development and production instances.

If everything worked for you then you should see this in your console:

A Web Developer by trade, find me on Github A motorcycle enthusiast at heart. Most days I'd rather be in the woods anywhere.