C# SDK

This topic provides instructions for installing the Constant Contact V3 C# (.NET) SDK.

Install

Install from the Package Manager console:

Install-Package ConstantContactApi

This pulls in the SDK's dependencies (RestSharp, Newtonsoft.Json, JsonSubTypes, Polly) automatically - no separate manual installs needed.

Using the API Client with an HTTP Proxy

To use the API client with an HTTP proxy, you must set up a System.New.WebProxy. For example:

Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;

Example

The following code example uses the AddAccountEmailAddress method to create a new account email address in a Constant Contact account.

using System.Collections.Generic;
using System.Diagnostics;
using ConstantContactApi.Api;
using ConstantContactApi.Client;
using ConstantContactApi.Model;

namespace Example
{
   public class Example
   {
     public static void Main()
     {

      Configuration config = new Configuration();
      config.BasePath = "https://api.cc.email/v3";
      // Configure OAuth2 accesstoken for authorization: oauth2_access_code
        config.AccessToken = "YOUR_ACCESS_TOKEN";
      // Configure OAuth2 access token for authorization: oauth2_implicit
        config.AccessToken = "YOUR_ACCESS_TOKEN";

        var apiInstance = new AccountServicesApi(config);
        var addAccountEmailAddressRequest = new AddAccountEmailAddressRequest(); // AddAccountEmailAddressRequest | A JSON request payload containing the new email address you want to add to the Constant Contact account.

        try
        {
            // POST Add an Account Email Address
            AddAccountEmailAddress201Response result = apiInstance.AddAccountEmailAddress(addAccountEmailAddressRequest);
            Debug.WriteLine(result);
        }
        catch (ApiException e)
        {
            Debug.Print("Exception when calling AccountServicesApi.AddAccountEmailAddress: " + e.Message );
            Debug.Print("Status Code: "+ e.ErrorCode);
            Debug.Print(e.StackTrace);
        }

      }
   }
}

Learn More

To learn more about this SDK, visit: