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

Eloqua REST API - How to Retrieve Contact Activities

$
0
0

In a previous post, we showed you how to Create and Manage Emails using the REST API. In today's post, we're going to demonstrate how to search for a Contact's activities. Please note that the code shared here expects that you know the ID of a Contact. You'll find several posts in the resource guide that will help you find Contacts using the API.

 

The complete source code for the examples shared here is available here on Github.

The models are available here.

 

The API supports the following types of Activity :

  • Email Open
  • Email Send
  • Email Click Through
  • Email Subscribe
  • Email Unsubscribe
  • Form Submit
  • Web Visit
  • Email Bounceback
  • Campaign Membership

 

Please note that the Activity endpoint in the API is currently readonly.

 

Let's start with a function (available in the sample project) that will invoke a request to retrieve the activities for a known Contact.

 

publicList<Activity>GetActivities(intcontactId,DateTimestartDate,DateTimeendDate,stringtype,int?count)        {            RestRequest request = new RestRequest(Method.GET)                                      {                                          RequestFormat = DataFormat.Json,                                          Resource = string.Format("/data/activities/contact/{0}?startDate={1}&endDate={2}&type={3}&count={4}",                                                            contactId, ConvertToUnixEpoch(startDate), ConvertToUnixEpoch(endDate), type, count)                                      };            IRestResponse<List<Activity>> response = _client.Execute<List<Activity>>(request);            return response.Data;
}

 

Next, we'll invoke a request to pull a list of Email Open activities for this Contact :

 

DateTime startDate = new DateTime(2012, 1, 1);
DateTime endDate = new DateTime(2012, 7, 1);
var activities= _activityHelper.GetActivities(320, startDate, endDate, Enum.GetName(typeof(ActivitySample.Models.ActivityType), 2), 10);

 

Please note that the REST API is not yet public and the code samples available here are my own work. I'll be glad to help support and fix issues in the code, but please understand that Eloqua will not be able to support this - as it is my own.

 

Thanks,
Fred


Viewing all articles
Browse latest Browse all 3423

Trending Articles