This article will walk you through how to use Get, Put, and Delete methods for Internet Records and builds on our two introductory articles, A 101 Look Into Our Rest Based API | Authentication Methods.
If you are using the Internet Address by InternetID Put method, you will need to designate the TypeID as follows.
Internet Types | |
TypeID |
Type
|
1
|
Email 1
|
2
|
Website 1
|
3
|
Email 2
|
4
|
Email 3
|
5
|
Website 2
|
The purpose of each of the methods are outlined below.
Internet Addresses by ContactID Fetch
Method Type: GET
returns a list of Internet Addresses records for a ContactID
'/contacts/{contactid}/internets'
Internet Address by InternetID Put
Method Type: PUT
creates or updates an Internet Address record by AddressID and Contact
'/contacts/{contactid}/internets/{internetid}' *
*{internetid} = {0} creates a new internet address record for a specific ContactID.
Internet Address by InternetID Delete
Method Type: POST
marks a record as deleted by InternetID
'contacts/{contactid}/internets/{internetid}'
To perform the GET and POST methods, all that is required is to provide the ContactID and InternetID in the URI and to provide the corresponding Method Type in the Request.
Internet Addresses by ContactID Fetch
The URI '/contacts/{contactid}/internets/{internetid}', when coupled with Method Type 'GET', returns a List of Internet Addresses 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 her Addresses using the URI below.
'contacts/{contactid}/internets'
https://api2.redtailtechnology.com/crm/v1/rest/contacts/384843/internets
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/internets"); 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.
Internet Address by InternetID PUT
With the Internet Address Put method you can create or update an Internet Address by its InternetID.
When Creating a new Internet Address record, an InternetID should be specified in the URI as '0'.
As always, when dealing with PUT methods, a Request Body must be provided to supply the record values. (Please Read our 101 article if you haven't already.)
What fields need to be supplied? The Required Fields are provided below in Bold.
Field | Datatype |
<RecID>*
<ClientID>
<TypeID>
<Address>
<Preferred>
|
integer
integer
string
string
boolean
|
*Note: The RecID is equivalent to the InternetID. Since you are supplying the InternetID in the URI, you do not need to specify the RecID.
To create a new record, we will specify, in our URI, the InternetID as equal to '0' and the ContactID for which the Internet Address is associated with. We will also need to provide the required fields in the request body.
https://api2.redtailtechnology.com/crm/v1/rest/contacts/{contactid}/Internets/{internetid}
Request Header example (C#)
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("https://api2.redtailtechnology.com/crm/v1/rest/contacts/384843/internets/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 = "{\"Address\":\"PinkIsKewl@hotmail.com\",\"ClientID\":384843,\"RecID\":0,\"TypeID\":1}"
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());
Internet Address by InternetID Delete
The URI '/contacts/{contactid}/internets/{internetid}', when supplied with the Method Type 'POST', marks an internet address record as deleted.
To delete an internet address, supply in the URI the specific InternetID and ContactID for the internet record you wish to remove.
Request Header example (C#)
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("https://api2.redtailtechnology.com/crm/v1/rest/contacts/313730/internets/321545");
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());
....
Comments