Contacts Search 'contacts/search' POST method

This Contacts' Search method is the new Search method in our arsenal. If you are not familiar with POST methods, do not fear. I will provide you with a practical example on this page. First, we will need to dig into the little details particular to this method

The purpose of this method is to retrieve a list of contacts with some of their more important details. The table below, on a request basis, will grow quite a bit larger than it currently is. As of right now, here's whats available.   

 

Search Fields
Enumerator
Field
Info
Operands Available
1
Name
Full Name
ALL
2
RecAdd
Add Date
ALL
3
PhoneNumber  
Phone Number  
ALL
4
Tag_Group
Tag Group
ALL
5
FirstName
First Name
ALL
6
LastName
Last Name
ALL
7
FamilyName
Family Name
ALL
8
FamilyHead
Head of Household
ALL
9
ClientStatus
Client Status
ALL
10
ContactType
Contact Entity Type (I, B, A, T, U)
ALL
11
ClientSource
Client Source
ALL
12
City
Client Address City
ALL
13
State
Client Address State
ALL
14
Zip
Client Address Zip
ALL
15
Employer
Client Employer
ALL
16
Email
Client Email
ALL
17
IntelliSearch
Searches against multiple data points (name, address, number, email, etc)
 
73
TaxId
Contact's Tax Identifier
ALL

 

The operands are enumerated as well. Here's how they mapped out.

Operands
Enumerator
Operand
0
Equals
1
Greater Than 
2
Less Than
3
Not Equal To
4
Like
5
Begins With
6
Is Empty?

 

Examples:

So to illustrate, here are a few examples in JSON with their SQL equivalents. You will be using similar JSON(Or XML) in your Request Body.

 

To return all of the clients updated since 2012-08-05

JSON:

[{"Field":"0","Operand":"1","Value":"2012-08-05"}]

The SQL Equivalent:

SELECT * FROM Table1 WHERE LastUpdate > '2012-08-05'

 

To retrieve a client with a TaxId Equivalent to '123-12-3123'.

JSON:

[{"Field":"73","Operand":"0","Value":"123123123"}]

The SQL Equivalent:

SELECT * FROM Table1 WHERE TaxId = '123123123'

 

To be more restrictive, you can search against multiple criteria.

For example, if you would like to retrieve a list of contacts named "John Smith", you can search against both the firstname and lastname fields as follows.

JSON:

[{"Field":"5","Operand":"0","Value":"John"},{"Field":"6","Operand":"0","Value":"Smith"}]

The SQL Equivalent:

SELECT * FROM Table1 WHERE firstname = 'john' AND lastname = 'smith'

 

Below is a sample record. If you are familiar with the 'Basic' Response used in some of our other Contact Fetch Methods, you will feel at home here.

Sample Record(JSON)
 
 


{"Contacts":[
{"ClientID":1626544,
"CompanyName":"General Electric",
"CompanyNameID":1627158,
"DatabaseID":0,
"Designation":"",
"DobDay":1,
"DobMonth":8,
"FamilyHeadID":0,
"FamilyName":"Dr. John Investor & Mrs. Mary Investor",
"FirstName":"Mary",
"IsFamilyHead":true,
"JobTitle":"HR Manager",
"LastName":"Investor",
"LastUpdate":"\/Date(-62135568000000-0800)\/",
"MiddleName":"J",
"Name":"",
"Nickname":"",
"Photo":"https:\/\/s3.amazonaws.com\/41974\/thumb.jpg",
"RecAddUser":0,
"Salutation":"Mrs.",
"SpouseName":"Dr. John (John) Investor",
"SpouseNameID":1626543,
"Suffix":"",
"TaxID":123-12-1234
"Type":"Individual",
"TypeID":"I"}],"TotalRecords":1}


 

 

Below is the sample request based on our first example. Notice that I've added the query string ?page=1. This is unnecessary for the first page, but you will want to specify the page # for any page thereafter. The method is paged for every 50 records returned.

 

Request Header example (C#)

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("https://api2.redtailtechnology.com/crm/v1/rest/contacts/search?page=1");
req.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes("6C135EDF-C37C-4039-AEF3-5DFC079F9E6A:statementone:sonedemo"));
req.Method = "POST";
req.ContentType = "text/json"; 


Request Body example (C#)

string reqJSON = "[{\"Field\":\"5\",\"Operand\":\"0\",\"Value\":\"Mary\"},{\"Field\":\"6\",\"Operand\":\"0\",\"Value\":\"Investor\"}]";
byte[] reqBody = System.Text.Encoding.ASCII.GetBytes(reqJSON);
req.GetRequestStream().Write(reqBody, 0, reqBody.Length);

//and here's the response stream.
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());

 

 Example Response(JSON)

{"Contacts":[{"ClientID":1626544,"CompanyName":"General Electric","CompanyNameID":1627158,"DatabaseID":0,"Designation":"","DobDay":1,"DobMonth":8,"FamilyHeadID":0,"FamilyName":"Dr. John Investor & Mrs. Mary Investor","FirstName":"Mary","IsFamilyHead":true,"JobTitle":"HR Manager","LastName":"Investor","LastUpdate":"\/Date(-62135568000000-0800)\/","MiddleName":"J","Name":"","Nickname":"","Photo":"https:\/\/s3.amazonaws.com\/ClientPhotos-RedtailCRM\/41974\/384843_thumbnail_07142010034156.jpg","RecAddUser":0,"Salutation":"Mrs.","SpouseName":"Dr. John (John) Investor","SpouseNameID":1626543,"Suffix":"","Type":"Individual","TypeID":"I"}],"TotalRecords":1}
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk