Follow

Phones By ContactID Methods '/contacts/{contactid}/phones'

 

This article will walk you through how to use Get, Put, and Delete methods for Phone Records and builds on our two introductory articles, A 101 Look Into Our Rest Based API | Authentication Methods.

If you are using the Phone by PhoneID Put method, you will need to designate the TypeID as follows.

Phone Types
TypeID
Type
HM
Home
CL
Cellular 
WK
Work
C2
Cellular 2
DD
Direct Dial
H2
Home 2
HF
Home Fax
OT
Other
O2
Other 2
PG
Pager
TF
Toll Free
W2
Work 2
WF
Work Fax


The purpose of each of the methods are outlined below.

Phones by ContactID Fetch

Method Type: GET

returns a list of Phone records for a ContactID

'/contacts/{contactid}/phones'

 

Phone by PhoneID Put

Method Type: PUT

creates or updates a Phone record by PhoneID and Contact

'/contacts/{contactid}/phones/{phoneid}' *

*{phoneid} = {0} creates a new phone record for a specific ContactID.

 

Phone by PhoneID Delete

Method Type: POST

marks a phone record as deleted by PhoneID

'contacts/{contactid}/addresses/{addressid}'


To perform the GET and POST methods, all that is required is to provide the ContactID and PhoneID in the URI and to provide the corresponding Method Type in the Request.

 

Phones by ContactID Fetch

 

The URI '/contacts/{contactid}/phones', when coupled with Method Type 'GET',  returns a List of Phone Records for a specific Contact Record.

 

A popular Contact used for testing in our test database is 'Mary Investor'. So we will retrieve a list of phones by her ContactID using the URI below.

'contacts/{contactid}/phones'

https://api2.redtailtechnology.com/crm/v1/rest/contacts/384843/phones

 

Below is a sample request in C# using our URI, sample credentials, and the method type. The content type "text/json" work equally well.

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("https://api2.redtailtechnology.com/crm/v1/rest/contacts/384843/phones");
req.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes("6C135EDF-C37C-4039-AEF3-5DFC079F9E6A:Statementone:sonedemo"));
req.Method = "GET";
req.ContentType = "text/xml";

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

 

The corresponding response(xml) will be similar to the following.

Phones.png

 

Phones by PhoneID PUT

 

With the Phone Put method you can create or update a Phone Record by PhoneID.

When Creating a new record, a PhoneID should not be specified. Instead, you will need to supply a '0' in its place.

As you know, a PUT method requires a Request Body accompanying the Request Header. (You know this because you've read our 101 article!)

 

What fields need to be supplied? The Required Fields are provided below in Bold.

 

Field Datatype

<RecID>
<ClientID>
<TypeID>
<Number>
<Preferred>


integer    
integer
string
string
boolean


 

To create a new record, we will specify the PhoneID in our URI as equal to '0' and supply the required fields in the request body.

 https://api2.redtailtechnology.com/crm/v1/rest/contacts/{contactid}/addresses/{addressid}

 

Request Header example (C#)

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

 

Request Body example (C#)

string reqJSON = "{\"ClientID\":384843,\"Number\":\"9258885859\",\"Preferred\":false,\"RecID\":0,\"TypeID\":\"HM\"}"
byte[] reqBody = System.Text.Encoding.ASCII.GetBytes(reqJSON);

//Request Stream
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());

 

 

Phone by PhoneID Delete

The URI '/contacts/{contactid}/phones/{phoneid}', when supplied with the Method Type 'POST',  marks a phone record as deleted.

To delete a phone record, provide the specific AddressID and ContactID in the URI.

Request Header example (C#)

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("https://api2.redtailtechnology.com/crm/v1/rest/contacts/313730/phones/112165");
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";

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

 

Request Body example (C#)


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

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk