Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.

FreshdeskClient.GetContacts Method

Jean-Sebastien Carle edited this page Jul 24, 2019 · 5 revisions

Overloads

Method Description
GetContacts() Retrieves all contacts and returns them as a single list object.
GetContacts(NameValueCollection) Retrieves contacts according to the filters specified and returns them as a single list object.

GetContacts()

Retrieves all contacts and returns them as a single list object.

public (Response, List<Contact>) GetContacts();

Returns

This method is returned as a Tuple.

Type Description
Response The server response that was returned by the request.
List<Contact> A list of contacts.

Examples

The following code example demonstrates this method.

using Freshdesk;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            string freshdeskDomain = "yourcompany.freshdesk.com";
            string apiKey = "yourapikey";
            FreshdeskClient freshdesk = new FreshdeskClient(freshdeskDomain, apiKey, "X");
            (Response response, List<Contact> contacts) = freshdesk.GetContacts();
            if (response.StatusCode == HttpStatusCode.OK)
                Console.WriteLine(contacts.Count);
        }
    }
}

Remarks

ℹ️ The Response StatusCode will return HttpStatusCode.OK if the contact was successfully retrieved.

⚠️ Caution should be used with this method. As long as the server returns a next page, results will continue to be aggregated to the list until there are no more pages. If the account contains a large number of contacts, this method may take a very long time to complete.


GetContacts(NameValueCollection)

Retrieves contacts according to the filters specified and returns them as a single list object.

public (Response, List<Contact>) GetContacts(NameValueCollection filter);

Parameters

Name Type Description
filter NameValueCollection A NameValueCollection of filters to apply to the request.

Returns

This method is returned as a Tuple.

Type Description
Response The server response that was returned by the request.
List<Contact> A list of contacts.

Examples

The following code example demonstrates this method.

using Freshdesk;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            string freshdeskDomain = "yourcompany.freshdesk.com";
            string apiKey = "yourapikey";
            FreshdeskClient freshdesk = new FreshdeskClient(freshdeskDomain, apiKey, "X");
            NameValueCollection filters = new NameValueCollection();
            filters.Add("email", "john.wick@hightable.org");
            (Response response, List<Contact> contacts) = freshdesk.GetContacts(filters);
            if (response.StatusCode == HttpStatusCode.OK)
                Console.WriteLine(contacts.Count);
        }
    }
}

Remarks

ℹ️ The Response StatusCode will return HttpStatusCode.OK if the contact was successfully retrieved.

⚠️ Caution should be used with this method. As long as the server returns a next page, results will continue to be aggregated to the list until there are no more pages. If the account contains a large number of contacts, this method may take a very long time to complete.

Clone this wiki locally