Quantcast
Channel: Topliners : All Content - All Communities
Viewing all articles
Browse latest Browse all 2909

Connecting to the Eloqua API - Generic Setup

$
0
0

In a number of code snippets we’ll be sharing in some upcoming posts,  there will be a bit of general setup that is common.  Rather than  repeat it in all the code snippets, it’s best just to share it once and  refer back to it.  This code, by itself, won't do much, but many of the code snippet samples that will be forthcoming may use this as a reference.

 

For almost anything you do with the Eloqua API, you will need the  SOAP endpoints for the calls defined.  There are two main endpoints  that we’ll be looking at, the External Action Service for Program  Builder related tasks (Cloud Connectors) and the standard SOAP endpoint  for many data and group related tasks.  This code snippet sets up both  as they will usually be used in tandem by most programs that leverage  the Eloqua API.

 

The following SOAP Endpoints are defined:

 

EloquaProgramService  as: https://secure.eloqua.com/api/1.2/ExternalActionService.svc?wsdl

 

and EloquaServiceNew as: https://secure.eloqua.com/API/1.2/Service.svc?wsdl

 

 

With  that, let’s create an object to manage our communication with Eloqua.   In creating an instance of this class, we’ll pass in three variables –  the Eloqua Instance  name, the User ID, and the Password.

 

The  Eloqua Instance name is the company name that you use on your login  page.  Your user id and password represent the user account for an  account that has API access.  To have API access, two things must be  true – the API must be enabled for your instance, and the account you  are using must have the right to use the API.  To turn on the API for  your install, just call the Eloqua support desk and ask them to enable  it for you.  Your system administrator will be able to grant access to  the API security rights under the Admin console.

 

With that set up, our constructor just creates a serviceProxy for each endpoint and attaches the credentials we have specified.  The Eloqua Instance Name and  the User ID are concatenated into a string that looks like  InstanceName\UserID.

 

    public class EloquaInstance

    {

 

        private EloquaServiceNew.EloquaServiceClient serviceProxy;

        private EloquaProgramService.ExternalActionServiceClient programServiceProxy;

 

        private DateTime dttLastEloquaAPICall;

       

        private string strInstanceName = "";

        private string strUserID = "";

        private string strUserPassword = "";

 

        public EloquaInstance(string InstanceName, string UserID, string UserPassword)

        {

            strInstanceName = InstanceName;

            strUserID = UserID;

            strUserPassword = UserPassword;

 

            serviceProxy = new EloquaServiceNew.EloquaServiceClient();

            serviceProxy.ClientCredentials.UserName.UserName = strInstanceName + "\\" + strUserID;

            serviceProxy.ClientCredentials.UserName.Password = strUserPassword;

 

 

            programServiceProxy = new EloquaProgramService.ExternalActionServiceClient();

            programServiceProxy.ClientCredentials.UserName.UserName = strInstanceName + "\\" + strUserID;

            programServiceProxy.ClientCredentials.UserName.Password = strUserPassword;

 

            ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

 

            dttLastEloquaAPICall = DateTime.Now.ToUniversalTime().Subtract(TimeSpan.FromMilliseconds(1000));

 

        }

 

    }

 

 

 

This generic setup will be  used by a lot of the code snippets we’ll share, and is a great way to  get you started with connecting to Eloqua.


Viewing all articles
Browse latest Browse all 2909

Trending Articles