Eloqua will soon be exposing our web services in the form of REST Resources. Eloqua already provides a Connecting to the Eloqua API - Generic Setup, well suited for integrated development environments like Eclipse and Visual Studio. These IDEs provide toolkits that can generate service proxies, making web services easy to use. The problem is that web services can be a challenge to work with when we don't have these proxies. REST APIs offer a lightweight alternative to web services and are easy to use with languages like Ruby and Python.

 

In this post, we'll introduce a request library written in Python that we're opening up to the community. The code is publicly available on Github at : fredsakr/eloqua-python-request · GitHub

The library supports the following operations :

  • GET
  • PUT
  • POST
  • DELETE

 

Let's look at a simple request using this library to search for Emails containing the word "Demand" :

 

We'll start by importing the library :

import sys
sys.path.append('./lib')
from eloqua_request import EloquaRequest

 

Next, we'll invoke a GET request to search for the Emails :

 

request = EloquaRequest('site', 'user', 'password')
response = request.get('/assets/emails?search=Demand*&page=1&count=50&depth=minimal', None)

 

The response for this call looks as follows :

 

{
  "elements": [
    {
      "type": "Email",
      "currentStatus": "Draft",
      "id": "86013",
      "createdAt": "1370981173",
      "createdBy": "9",
      "depth": "minimal",
      "folderId": "1422",
      "name": "Demand.html",
      "permissions": "fullControl",
      "updatedAt": "1370981173",
      "updatedBy": "9",
      "htmlContent": {
        "type": "RawHtmlContent",
        "contentSource": "upload"
      }
    },
    {
      "type": "Email",
      "currentStatus": "Draft",
      "id": "69830",
      "createdAt": "1362380717",
      "createdBy": "244",
      "depth": "minimal",
      "folderId": "1422",
      "name": "Demand Sample",
      "permissions": "fullControl",
      "updatedAt": "1362380784",
      "updatedBy": "244",
      "htmlContent": {
        "type": "RawHtmlContent",
        "contentSource": "upload"
      }
    },
   ...
  ],
  "page": 1,
  "pageSize": 10,
  "total": 130
}

 

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