In this post, we'll demonstrate how to search for contacts in the REST API using c#.

If you're new to c# and RESTful APIs, please see the following post on making API requests using c#.


Let's start by defining a model for the Contact record :


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; }


Next, we'll provide you with a function that will invoke an HTTP GET request to search for Contacts using the API.

Please note that a complete working sample of this code is available here on Github.


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

            IRestResponse<RequestObjectList<Contact>> response = _client.Execute<RequestObjectList<Contact>>(request);

            List<Contact> contacts = response.Data.elements;

            return contacts;


Finally, we'll execute a search for all contacts whose email address ends with "" :


List<Contact>contacts =_contactHelper.SearchContacts("*",1,100);


We hope that you find this useful.


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.