Follow

User-Defined Fields By ContactID Methods '/contacts/{contactid}/udf'

 

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

If you would like to retrieve the list of User-Defined Fields for a database, you should take a look at our '/settings/udf' method  User-Defined Fields Fetch

 

The purpose of each of the methods are outlined below.

UDFs by ContactID Fetch

Method Type: GET

returns a list of User-Defined fields for a Contact record.

'/contacts/{contactid}/udf'

 

UDF By User-Defined Field ID Put

Method Type: PUT

creates or updates a User-Defined field based on the User-Defined Field ID.

'/contacts/{contactid}/udf/{udfid}' *

*{udfid} = {0} creates a new UDF record for a specific ContactID.

 

UDFs By ContactID Fetch

 

The URI '/contacts/{contactid}/udf', when paired with the Method Type 'GET',  returns a List of UDF Records for a specific Contact.

 

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

'contacts/{contactid}/udf'

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

 

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/udf");
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.

 

 

UDF By User-Defined Field ID PUT

With this method you can create or update a UDF Record by its Unique Identifier

When Creating a new record, the UDFID should not be specified or you can 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!)

 

To create a new record, we will specify the UDFID 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}/udf/{udfid}

 

Request Header example (C#)

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("https://api2.redtailtechnology.com/crm/v1/rest/contacts/384843/udf/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,\"Field\":2019",\"FieldName\":\"Musical Preference\",\"RecID\":0,\"Value\":\"Classical\"}"
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());

 

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

Comments

Powered by Zendesk