Skip navigation
1 2 3 4 Previous Next

Code It

58 Posts authored by: fsakr

The REST API provides access to create, retrieve, update and delete External Assets.

 

Accessing External Asset Types

  • GET :  /assets/external/types?depth=complete

 

Accessing External Assets

  • GET :  /assets/external/{id}?depth={depth}

 

Response

The response for this call looks as follows :

 

{
  "elements": [
    {
      "type": "ExternalAssetType",
      "id": "2",
      "createdAt": "1256486517",
      "depth": "complete",
      "name": "Tradeshow Sample",
      "updatedAt": "1369168490",
      "updatedBy": "23",
      "activityTypes": [
        {
          "type": "ExternalActivityType",
          "id": "1017",
          "createdAt": "1369168490",
          "createdBy": "23",
          "depth": "complete",
          "name": "Attended",
          "updatedAt": "1369168490",
          "updatedBy": "23"
        },
        {
          "type": "ExternalActivityType",
          "id": "1016",
          "createdAt": "1369168490",
          "createdBy": "23",
          "depth": "complete",
          "name": "Registered",
          "updatedAt": "1369168490",
          "updatedBy": "23"
        },
        {
          "type": "ExternalActivityType",
          "id": "1003",
          "createdAt": "1256486517",
          "depth": "complete",
          "name": "Viewed Demo",
          "updatedAt": "1369168490",
          "updatedBy": "23"
        },
        {
          "type": "ExternalActivityType",
          "id": "1002",
          "createdAt": "1256486517",
          "depth": "complete",
          "name": "Visited Booth",
          "updatedAt": "1369168490",
          "updatedBy": "23"
        }
      ]
    },
    {
      "type": "ExternalAssetType",
      "id": "3",
      "createdAt": "1347550426",
      "createdBy": "146",
      "depth": "complete",
      "name": "Direct Mail",
      "updatedAt": "1371612452",
      "updatedBy": "14",
      "activityTypes": [
        {    …   }
   }

 

Properties

 

 

Name

Type

Description

Notes

Validation

type

“ExternalAsset”

 

 

 

id

integer

The unique identifier for the External Assset

ReadOnly

 

name

string

 

 

 

createdAt

long

 

 

 

createdBy

integer

 

 

 

updatedAt

long

 

 

 

updatedBy

integer

 

 

 

 

Related Operations

  • SEARCH :  /assets/externals?depth={depth}&count={count}&page={page}&search={search}&orderBy={orderBy}&lastUpdatedAt={lastUpdatedAt}
  • POST :  /assets/external
  • PUT :  /assets/external/{id}
  • DELETE :  /assets/external/{id}

 

 

We hope that you find this helpful and please let us know if you need more information.

 

Thanks,

Fred

The REST API provides access to create, retrieve, update and delete Email Folders.

 

Accessing Email Folders

  • GET :  /assets/email/folders?depth={depth}&count={count}&page={page}&search={search}&orderBy={orderBy}&lastUpdatedAt={lastUpdatedAt}

 

Response

The response for this call looks as follows :

 

{
  "elements": [
    {
      "type": "Folder",
      "id": "42",
      "createdAt": "1172514464",
      "depth": "complete",
      "description": "Root",
      "name": "Email Group Root",
      "updatedAt": "1378173465",
      "updatedBy": "116",
      "isSystem": "true"
    },
    {
      "type": "Folder",
      "id": "43",
      "createdAt": "1172514464",
      "depth": "complete",
      "folderId": "250",
      "name": "My Emails",
      "updatedAt": "1336754427",
      "updatedBy": "28",
      "isSystem": "false"
    },
    {
      "type": "Folder",
      "id": "44",
      "createdAt": "1172514464",
      "depth": "complete",
      "folderId": "250",
      "name": "Newsletter",
      "updatedAt": "1335871832",
      "updatedBy": "46",
      "isSystem": "false"
    },
  ],
  "page": 1,
  "pageSize": 10,
  "total": 301
}
 

 

Properties

 

Name

Type

Description

Notes

Validations

type

Folder

 

 

 

id

integer

The unique identifier of the Folder

ReadOnly

IdRequirement

isSystem

boolean

Identifies a system generated Folder

ReadOnly

 

name

string

The Folder’s name

 

 

 

Related Operations :

GET :  /assets/email/folder/{id}?depth={depth}

POST :  /assets/email/folder

PUT :  /assets/email/folder/{id}

DELETE :  /assets/email/folder/{id}

 

We hope this helps and please let us know if you have any questions.

 

Thanks,

Fred

fsakr

Bulk API - .NET SDK

Posted by fsakr Aug 23, 2013

The results of our poll (Let's write some code together) are in and .NET came in second place! We're excited to announce that we've started a .NET SDK Project to help developers building on the Bulk API.

 

The project is open source and currently supports the following operations :

  • Contact Exports
  • Contact Imports
  • Custom Object Exports
  • Custom Object Imports
  • Account Exports
  • Account Imports

 

This is an open source project and we encourage contributions from the community. The project is available on Github or you can clone it from : fredsakr/eloqua-csharp-sdk · GitHub

 

The Winter release is scheduled to include support for Exporting Activity Data and we'll aim to have it supported by this client on Day 1.

 

Usage

 

Create Client

var info = BulkClient.GetAccountInfo(site, user, password);
var client = new BulkClient(site, user, password, info.Urls.Apis.Rest.Bulk);


 

Search Assets

List<ContactFilter> filters = _client.ContactFilters.Search(searchTerm, page, count);


 

Create Export

Export export = new Export
{
    name = "sample export",
    fields = fields,
    filter = filter,
    secondsToAutoDelete = 3600,
    secondsToRetainData = 3600,
};

var exportResult = client.ContactExport.CreateExport(export);

Sync sync = new Sync
            {
                status = SyncStatusType.pending,
                syncedInstanceUri = exportResult.uri
            };
var syncResult = _client.ContactExport.CreateSync(sync);

var data = _client.ContactExport.GetExportData(exportResult.uri);


 

Please note that these libraries are not written or supported by Eloqua. Questions about these libraries can be directed to the author on Github or here on Topliners.

 

We hope that you find this helpful and please let us know if you have any questions.

 

Thanks,

Fred

fsakr

Bulk API - Java SDK

Posted by fsakr Aug 15, 2013

Attention developers - the results of our poll (Let's write some code together) are in and a majority of people are looking for Java! We're excited to announce that we've started a Java SDK project to help developers building on the Bulk API. The project is open source and currently supports the following operations :

  • Contact Exports
  • Contact Imports
  • Custom Object Exports
  • Custom Object Imports
  • Account Exports
  • Account Imports

 

Grab a copy from Github and check for updates.

 

Create Client

AccountInfo info = BulkClient.GetAccountInfo("site", "user", "password");
BulkClient client = new BulkClient("site", "user", "password", info.urls.apis.rest.bulk);




 

Search

SearchResponse<Field> fields = client.ContactFieldClient().Search(searchTerm, page, count);

 

 

Contact Export

// instantiate a new instance of the client
// String baseUrl = BulkClient.GetAccountInfo(site, user, password);
BulkClient client = new BulkClient("site", "user", "password", "https://secure.eloqua.com/API/Bulk/1.0");

// define the list of fields to be included in the Export
// use : client.ContactFieldClient().Search(searchTerm, page, pageSize)
HashMap<String, String> fields = new HashMap<String, String>();
fields.put("C_EmailAddress", "{{Contact.Field(C_EmailAddress)}}");
fields.put("C_FirstName", "{{Contact.Field(C_FirstName)}}");

// define the filter criteria for the export
// use : client.ContactFilterClient().Search(searchTerm, page, pageSize)
ExportFilter filter = new ExportFilter();
filter.filterRule = FilterRuleType.member;
filter.membershipUri = "/contact/segment/4268";

// create the definition for the Export
Export export = new Export();
export.name = "sample export";
export.fields = fields;
export.filter = filter;
export.secondsToAutoDelete = 3600;
export.secondsToRetainData = 3600;

Export exportResult = client.ContactExportClient().CreateExport(export);

// create the sync for the Export
Sync sync = new Sync();
sync.status = SyncStatusType.pending;
sync.syncedInstanceUri = exportResult.uri;

// check Sync results (use polling)
Sync syncResult = client.ContactExportClient().CreateSync(sync);

// retrieve the data
Data data = client.ContactExportClient().GetExportData(exportResult.uri);



 

Response

A sample response for this call :

{
  "values": [
    {
      "C_FirstName": "Fred",
      "C_EmailAddress": "fred.sakr@oracle.com"
    },
    {
      "C_FirstName": "T.J.",
      "C_EmailAddress": "tj.fields@oracle.com"
    },
    {
      "C_FirstName": "Modern",
      "C_EmailAddress": "modern.mark@e..."
    ..}
  ]
}

 

 

The Winter release is scheduled to include support for Exporting Activity Data and we'll aim to have it supported by this client on Day 1.

 

Please note that these libraries are not written or supported by Eloqua. Questions about these libraries can be directed to the author on Github or here on Topliners.

We hope that you find this helpful and please let us know if you have any questions.

 

Thanks,

Fred

The Rest API provides access to create and retrieve External Activities for known contacts. For more information on External Activities, see the following Summer Release Notes.

 

Accessing External Activities

  • GET :  /data/activity/{id}

 

Response

The response for this call looks as follows :

 

{
  "type": "ExternalActivities",
  "id": "35",
  "depth": "complete",
  "name": "Eventbrite",
  "activityDate": "1362543780",
  "activityType": "Registration",
  "assetName": "Eventbrite",
  "assetType": "Event",
  "contactId": 44891
}

 

Properties

 

Name

Type

Description

Notes

Validations

type

"ExternalActivities"

activityDate

integer

The date of the activity

DateRequirement

activityType

string

The type of activity

EnumRequirement

assetName

string

assetType

string

contactId

integer

The id of the contact who performed the activity

IdRequirement

campaignId

integer

The id of the contact associated with this activity

id

string

The unique identifier of the activity

 

Related Operations

  • POST :  /data/activity

 

We hope that you find this helpful and please let us know if you have any questions.

 

Thanks,

Fred

We are pleased to announce that a new version of our Rest Client is now available via NuGet. And sources, documentation as well as a community site are now hosted on Codeplex.


Documentation | Community

 

 

For anyone currently using the sources on Github, note that we’ll continue to maintain both sites, but NuGet will be the recommended source for using the client in your own projects.


Getting the C# Rest Client Library using NuGet

  1. Using the NuGet Package Manager Console :
    • Install-Package Eloqua.Api.Rest.ClientLibrary
  2. Using Visual Studio 2012
    • Right-click on the project's references
    • Select "Manage NuGet Package..."
    • Search for "Eloqua Client Library"

 

There are two versions of the Rest API Client – note that the Eloqua.Api.Rest.ClientLibrary is the current version and EloquaClient is the original work. Please use Eloqua.Api.Rest.ClientLibrary going forward.

 

 

We hope that you find this helpful and please let me know if you have any questions.


Thanks,

Fred

 

Disclaimer

Please note that these are my own tools and are meant to help developers build on the Eloqua platform and while I am happy to answer questions and provide support, note that Eloqua is not responsible for and cannot support this product.

fsakr

REST API - Uploading Images

Posted by fsakr Jul 22, 2013

The REST API provides access to retrieve and upload images.

 

Accessing Image Folders

  • GET :  /assets/image/folder/root/folders

 

Response

The response for this call looks as follows :

 

{
  "elements": [
    {
      "type": "Folder",
      "id": "319",
      "createdAt": "1263744559",
      "depth": "minimal",
      "description": "Eloqua Logo",
      "folderId": "318",
      "name": "Eloqua Logo",
      "updatedAt": "1374228103",
      "updatedBy": "573",
      "isSystem": "true"
    },
    {
      "type": "Folder",
      "id": "625",
      "createdAt": "1289591446",
      "createdBy": "11",
      "depth": "minimal",
      "folderId": "318",
      "name": "Sample Images",
      "updatedAt": "1372706467",
      "updatedBy": "503",
      "isSystem": "false"
    },
    {
      "type": "Folder",
      "id": "870",
      "createdAt": "1291340355",
      "createdBy": "9",
      "depth": "minimal",
      "folderId": "318",
      "name": "Sample",
      "updatedAt": "1372024637",
      "updatedBy": "497",
      "isSystem": "false"
    },
    ...
  ],
  "page": 1,
  "pageSize": 1000,
  "total": 162
}

 

Uploading Images

  • POST :  assets/image/content
  • Content type : image/jpeg

 

Response

The response for this call looks as follows :

 

{
  "type": "ImageFile",
  "id": "13077",
  "createdAt": "1374505145",
  "createdBy": "340",
  "depth": "complete",
  "folderId": "318",
  "name": "sample.jpg",
  "updatedAt": "1374505146",
  "updatedBy": "340",
  "fullImageUrl": "\/EloquaImages\/clients\/ORSE\/{ffaa51ba-220e-43da-994f-197338be7d35}_sample.jpg",
  "size": {
    "type": "Size",
    "width": "577",
    "height": "577"
  },
  "thumbnailUrl": "\/EloquaImages\/clients\/ORSE\/imagethumbnails\/{ffaa51ba-220e-43da-994f-197338be7d35}_sample.jpg"
}

 

Code Samples

 

We hope that you find this helpful and please let us know if you have any questions.

 

Thanks,

Fred

fsakr

Securing your Software

Posted by fsakr May 17, 2013

This was originally posted in the Tips and Tricks thread and I thought it would be helpful to share with the Code It group.

 

The best way to secure your product, is building security in from the start. Most businesses view security as a priority, but software developers rarely apply this in their daily work and often find security vulnerabilities too late in the development lifecycle. Large organizations typically require exhaustive security requirements while smaller companies may cover only the essentials and both can provide very different levels of security. The problem is : big or small, we're all exposed to the same vulnerabilities and whether you're building web applications or server side architectiure, security should play an integral part of the software lifecycle.

 

Almost all software security vulnerabilities are the result of poor design and engineering. Programmers focus on building features and sometimes defer security to separate departments in the organization - those focused on security. While these teams are great, they don't have the same insight into the design or visibility into the source code. Developers are ultimately responsible for securing their software. As the complexity of the software increases, so does the trouble in managing the risk. To make life easier, build in security from the requirements phase (use cases and abuse cases) to the final stage of analysis of feedback received from the field (security breaks).

 

When planning and building software, it helps to understand how an attacker thinks and how they would exploit it. Attackers are pragmatic and tend to have a lot of free time. If functionality is about what an application can do, security is about what an application should not do. Software developers should know and understand the most commonly used attack patterns and should be familiar with more comprehensive lists applicable to their space. Knowledge is the best defense.

 

The following list is not exhaustive, but covers some of the most common types of attack patterns :

Cross-site scripting (XSS)

Cross-site request forgery (CSRF)

Argument injection (SQL injection)

Command delimiters

Simple script injection

Failure to handle errors

Race Conditions

HTTP query strings

User-supplied variable

URL encoding

Direct access to executable files

Sessions and blind trust

User controlled filename

Parameter expansion

Relative path traversal

Buffer overflow

Programs that access resources

 

There are many techniques to prevent these attacks, including threat modeling, good coding standards, code reviews, static code analysis, runtime monitoring, and many more. Traditionally, the focus of software security was on the OS and network layers, but recently more attention is focusing on web applications and browsers. As a developer, the best thing to do is be aware and build security in at every stage.

 

Software security can be a thankless job. When the system is secure, everything behaves as expected and you’re rarely noticed. But as soon as an attack occurs, all the lights will shine on you.

 

Better be prepared.

 

Fred

We are pleased to announce that version 1.0 of the open source C# Rest client is now available via NuGet. And sources, documentation as well as a community site are now hosted on Codeplex.

 

Documentation | Community

 

 

 

For anyone currently using the sources on Github, note that we’ll continue to maintain both sites, but NuGet will be the recommended source for using the client in your own projects.

 

Getting the C# Rest Client via NuGet

  1. Using the NuGet Package Manager Console :
    • Install-Package Eloqua.Api.Rest.ClientLibrary
  2. Using Visual Studio 2012
    • Right-click on the project's references
    • Select "Manage NuGet Package..."
    • Search for "Eloqua Client"

 

 

We hope that you find this helpful and please let me know if you have any questions.


Thanks,

Fred

 

Disclaimer

Please note that these are my own tools and are meant to help developers build on the Eloqua platform and while I am happy to answer questions and provide support, note that Eloqua is not responsible for and cannot support this product.

fsakr

Eloqua API Chart

Posted by fsakr Jan 3, 2013

The following chart identifies some API operations available with different versions of the Eloqua product. Please note that the document is not exhaustive.

 

 

E10E9RESTSOAP
Core ObjectsCreateRetrieveUpdateDeleteCreateRetrieveUpdateDelete
Accounts

X

X

X

X

X

X

X

X

XX
Activities

X

X

XX
Campaigns

X

X

X

X

X

X
Contacts

X

X

X

X

X

X

X

X

XX
Contact Fields

X

X

X

X

X

XX
Contact Lists

X

X

X

X

X

X
Content Sections

X

X

X

X

X
Custom Objects Metadata

X

X

XX
Custom Objects Data

X

X

X

X

X

X

XXXX
EmailsX

X

XXX

X

XXX
Email Deployment

X

X

 

 

X

 

XX
Forms

X

X
Form DataX

X

XX

X

X

X

X

XX
Landing Pages

X

X

X

X

X
Microsites

X

X

X

X

X
Prospects

X

X

X

X

X
Users

X

X
VisitorsXXXX

X

X

X

X

X

 

We hope that you find this helpful.

In this post, we'll show you how to retrieve Activity data using the SOAP API. We'll assume that you're already familiar with how to connect to the API, but please see the following post (Connecting to the API) for more information.

 

The API exposes activities for the following assets :

  • Email
    • Email Open
    • Email Send
    • Email Subscribe
    • Email Unsubscribe
    • Email Click Through
  • Form
  • Web

 

The response for each activity will include a dictionary of details, related to the activity type.

 

For example, the Email Send activity will contain the following details :

  • Email Web Link
  • Email Name
  • Email Recipient ID
  • Subject Line

 

Let's look at a quick sample for retrieving some Email Send Activities :

 

We'll start by creating a new instance of the Eloqua Service :

 

            // Create a new instance of the service proxy
            var service = new EloquaService.EloquaServiceClient();
            service.ClientCredentials.UserName.UserName = "site\\user";
            service.ClientCredentials.UserName.Password = "password";

 

Next, we'll execute a request to list all of the Activity Types available :

 

            var types = service.ListActivityTypes();
            foreach (var type in types.ActivityTypes)
            {
                Console.WriteLine(type);
            }

 

Note that you will need to have a known Contact in order to retrieve activity data. Let's look at a simple request to retrieve a Contact by their email address :

 

            // Search for and identify a known Contact
            var entityType = new EntityType() { Type = "Base", Name = "Contact" };
            var queryResult = service.Query(entityType, "C_EmailAddress=fred.sakr@eloqua.com", null, 1, 1);
            var entity = queryResult.Entities[0];

 

Next, we'll build a list of Activity Types that we want to retrieve for this contact. In our example, we'll request Email Send activities :

 

            // Define the list of Activity Types to query for
            var activityTypes = new List<ActivityType>();
            activityTypes.Add(ActivityType.EmailSend);

 

We'll also provide the start and end date for the Activity data :

 

            // Define start and end dates for Activities
            var startDate = DateTime.Now.AddMonths(-3);
            var endDate = DateTime.Now;

 

Finally, we'll invoke a request to retrieve the activity data for this Contact :

 

            // Execute a request to retrieve a list of Activities
            var activityResult = service.GetActivities(entity, activityTypes.ToArray(), startDate, endDate);

 

And we'll loop through and write the data to the console :

 

            foreach (var item in activityResult)
            {
                Console.WriteLine("Activity Type: " + item.ActivityType);

                // Activity Details
                foreach (var detail in item.FieldValueCollection)
                {
                    Console.WriteLine(detail.Key + " : " + detail.Value);
                }
            }


 

We hope that you find this helpful.

 

Thanks,

Fred

We recently added an open source PHP Rest Client to help make requests to Eloqua's API a little easier. In today's post, we'll show you how to create and manage Landing Pages using the client.

Let's start by including and instantiating a new instance of the client :

 

// include the Rest client
include_once('lib/eloquaRequest.php');
$client = new EloquaRequest('site', 'user', 'password', 'https://secure.eloqua.com/API/REST/1.0/');

 

Next, let's define a class to represent a Landing Page record :

 

class LandingPage
    {
        public $createdAt;
        public $createdBy;
        public $htmlContent;
        public $id;
        public $name;
        public $updatedAt;
        public $updatedBy;
    }

 

Note that the HTML Content property is a complex type, represented by the following class :

 

class RawHtmlContent
    {
        public $type;
        public $html;
    }

 

Search Landing Pages

The following sample invokes a GET request to search for Landing Pages matching "Demand*" :

 

$list = $client->get('assets/landingPages?search=Demand*&count=50&page=1&depth=complete');

 

Create a Landing Page

The following sample creates a new Landing Page object and invokes an HTTP POST request to create the record :

 

$lp = new LandingPage();
$lp->name = 'sample landing page';
$htmlContent = new RawHtmlContent();
$htmlContent->html = '<html><head></head><body>sample content</body></html>';
$lp->htmlContent = $htmlContent;
$response = $client->post('assets/landingPage', $lp);

 

Update a Landing Page

The following sample invokes an HTTP PUT request to update an existing Landing Page.

 

$updatedLP = new LandingPage();
$updatedLP->id = $response->id;
$updatedLP->name = 'updated sample name';
$updatedLP = $client->put('/assets/landingPage/' . $updatedLP->id, $updatedLP);

 

Delete a Landing Page

The following sample invokes an HTTP DELETE request to delete an existing Landing Page

 

$client->delete('/assets/landingPage/' . $updatedLP->id);

 

We hope that you find this helpful.

 

Thanks,

Fred

fsakr

Eloqua REST API - User Access

Posted by fsakr Oct 20, 2012

In a previous post, we introduced the Rest API with an overview of Email management and deployment. In today's post, we'll introduce the User record.

 

URL : GET /system/user/{id}?depth={depth}

 

public class User
    {
        public List<string> betaAccess { get; set; }
        public List<string> capabilities { get; set; }
        public int? defaultContactViewId { get; set; }
        public string emailAddress { get; set; }
        public int? id { get; set; }
        public string loginName { get; set; }
        public string name { get; set; }
        public List<ProductPermission> productPermissions { get; set; }
        public List<TypePermissions> typePermissions { get; set; }
}
  

 

The user record contains information such as the beta access flags that are enabled as well as the areas of the application the user can access.

The sample project contains methods for retrieving a user and searching for lists of users. Note that a user create operation is not yet supported in the API.

 

A new open source project containing samples and helper methods for working with the user object is available here on Github.

Let's look at a sample json representation of the user object :

 

"type": "User",
      "id": "9",
      "createdAt": "1260902519",
      "createdBy": "8",
      "depth": "complete",
      "description": "John Smith",
      "name": "John Smith",
      "updatedAt": "1350572309",
      "updatedBy": "9",
      "betaAccess": [    
        "archiving_campaigns",
        "chatter_inside",
],
      "capabilities": [
        "mailer.updateContacts"
      ],
      "company": "OrionTest",
      "defaultAccountViewId": "100124",
      "defaultContactViewId": "100084",
      "emailAddress": "john.smith@eloqua.com",
      "loggedInAt": "1350686543",
      "loginName": "John.Smith",
      "preferences": {
        "type": "UserPreferences",
        "isMasterViewDocked": "false",
        "timezoneId": "64"
      },
      "productPermissions": [
        {
          "type": "ProductPermission",
          "productCode": "SecureHypersites"
        },
        {
          "type": "ProductPermission",
          "productCode": "EngageiPad"
        },
        {
          "type": "ProductPermission",
          "productCode": "EngageWeb"
        }
      ],
      "typePermissions": [
        {
          "type": "TypePermission",
          "objectType": "Campaign",
          "permissions": {
            "type": "TypePermissions",
            "create": "true",
            "read": "true"
          }
        },
        {
          "type": "TypePermission",
          "objectType": "Email",
          "permissions": {
            "type": "TypePermissions",
            "create": "true",
            "read": "true"
          }
     }
}
   

 

We hope that you find this helpful.

 

Thanks,

Fred

In a previous post, we demonstrated how to Search for Contacts using the Rest API. In today's post, we'll show you how to update a Contact's email address.

A complete sample project containing all of the code samples and model definitions is available here on Github.

 

The sample project on Github contains helper methods for the following operations :

  • Retrieve a single Contact
  • Search for a list of Contacts
  • Create and Update a Contact
  • Delete a Contact

 

Let's start by looking at the definition of a Contact record in the API :


public class Contact
    {
        public string accountName { get; set; }
        public string address1 { get; set; }
        public string address2 { get; set; }
        public string address3 { get; set; }
        public string businessPhone { get; set; }
        public string city { get; set; }
        public string country { get; set; }
        public string emailAddress { get; set; }
        public string firstName { get; set; }
        public int? id { get; set; }
        public string lastName { get; set; }
        public bool? isSubscribed { get; set; }
        public bool? isBounceBack { get; set; }
        public string salesPerson { get; set; }
        public string title { get; set; }
        public List<FieldValue> fieldValues { get; set; }
    }

 

Let's now look at the steps to update a Contact's email address using the API. We'll first need to identify the contact record.

There are two ways you can do this:

  1. Known Contact ID
  2. Search for the Contact

 

If you already know the ID of the contact you're working with, you can use the following method to retrieve the contact :

public Contact GetContact(int id)
        {
            var request = new RestRequest(Method.GET)
                              {
                                  Resource = "/data/contact/" + id
                              };

            var response = _client.Execute<Contact>(request);
            return response.Data;
        }


If you need to discover or search for your contact record, you can use the following method :

public RequestObjectList<Contact>SearchContacts(string searchTerm,int page,int pageSize)
        {
            var request = new RestRequest(Method.GET)
                              {
                                  Resource =
                                      string.Format("/data/contacts?depth=complete&search={0}&page={1}&count={2}",
                                                    searchTerm, page, pageSize)
                              };

            var response = _client.Execute<RequestObjectList<Contact>>(request);
            return response.Data;
        }


Finally, the project contains a method to update your contact record :

 

public Contact UpdateContact(Contact contact)
        {
            var request = new RestRequest(Method.PUT)
                              {
                                  Resource = "/data/contact/" + contact.id,
                                  RequestFormat = DataFormat.Json
                              };
            request.AddBody(contact);

            var response = _client.Execute<Contact>(request);
            return response.Data;
}


We hope that you find this helpful.


Thanks,

Fred


In a previous post, we discussed how to Send Email using the Rest API. In today's post, we'll discuss how to retrieve the statistics for your email deployment.

For a reference as well as a complete sample project on working with and sending Emails using the Rest API, please see the following Github repository.

 

Sending an Email using the API can be done by submitting a POST request to the following endpoint :

The response from the Post request will contain the unique ID for this deployment.

 

Once the email has been delivered, we can query the same endpoint (GET https://secure.eloqua.com/API/REST/1.0/assets/email/deployment/{id}) to retrieve a some statistics regarding the email delivery.

The EmailDeployment object contains a property that defines these statistics : EmailDeploymentStatistics

 

public class EmailInlineDeployment : EmailDeployment
    {
        public int? clickthroughCount { get; set; }
        public List<Contact> contacts { get; set; }
        public int? openCount { get; set; }
        public int? sendFromUserId { get; set; }
        public List<EmailDeploymentStatistics> statistics { get; set; } 
    }

 

Let's look at the EmailDeploymentStatistics object in detail.

 

public class EmailDeploymentStatistics
    {
        public string bouncebackType { get; set; }
        public int? clickThroughCount { get; set; }
        public string emailAddress { get; set; }
        public long? lastClickThrough { get; set; }
        public long? lastOpen { get; set; }
        public int? openCount { get; set; }
        public long? sentAt { get; set; }
    }

 

We hope that you find this helpful. Please note that the REST API is not yet public and the code samples referenced here are my own work. I'll be glad to support it, but please understand that Eloqua will not be able to support this code.

 

Thanks,

Fred