In the post Eloqua API How To: Query a Contact by Email Address, I showed how to use the Where can I find the documentation for the Eloqua API to retrieve contacts by a single field (in this case Email Address). 

 

But what if we want to narrow down the results by passing multiple fields into the query?

 

Well, the Eloqua API does support passing in multiple fields, and here's how it's done...

 

Using a piece of the Eloqua API How To: Query a Contact by Email Address, all we need to do is modify the searchQuery string, adding in the fields that we want to search on separated by and.

 

 

         static void Main()

         {

                         const string searchQuery = "C_FirstName='John' and C_LastName='Doe'";


            try
            {
               //Create the service instance using your credentials

               EloquaInstance service = new EloquaInstance("instance", "userid", "password");
               
                // Instantiate a Contact Entity Type
                EntityType contactEntityType = new EntityType
                                            {
                                                ID = 0,
                                                Name = "Contact",
                                                Type = "Base"
                                            };

                // Create a new list containing the fields you want populated
                List<string> fieldList = new List<string> { "C_EmailAddress", "C_FirstName", "C_LastName" };
             
                // Define a container for the Query results
                DynamicEntityQueryResults queryResult;


 

That's all there is to it!

 

The code above uses the First and Last name fields, but you can use any contact field you wish.