We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

field with comma while importing contacts via API


field with comma while importing contacts via API

Hi there,


Since the list via API gets uploaded in csv, is there a way to handle the field that has a comma in them. For example, one of the fields in my list (dealer name) has a comma - ABC, Inc. When this gets imported to constant contact, the fields gets messed up due to comma in the field. Is there a way to fix this?


Attached is few lines of code that I have.

CredentialCache LoginCredentials = new CredentialCache();
                    LoginCredentials.Add(new Uri("https://api.constantcontact.com/ws/customers/" + uName), "Basic", new NetworkCredential(APIKey + '%' + uName, pWord));
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.constantcontact.com/ws/customers/" +
                        uName + "/activities");
                    request.Credentials = LoginCredentials;
                    request.Method = "POST";
                    request.ContentType = "application/x-www-form-urlencoded";
                    sListUri = "https://api.constantcontact.com/ws/customers/" + uName + "/lists/6";
                    StringBuilder data = new StringBuilder();
                    data.Append("activityType=" + HttpUtility.UrlEncode("SV_ADD", Encoding.UTF8));
                    data.Append("&data=" + HttpUtility.UrlEncode(("Email Address,First Name,Last Name,Company Name,CUSTOM FIELD 1,CUSTOM FIELD 2,CUSTOM FIELD 3,CUSTOM FIELD 4, CUSTOM FIELD 5 " + "\n"), Encoding.UTF8));
                    data.Append(HttpUtility.UrlEncode((sdr["EmailAddress"].ToString() + ",\"" + sdr["FirstName"].ToString() + "\",\"" + sdr["LastName"].ToString() + "\"," + sdr["Company"].ToString() + "," + sdr["Website"].ToString() + "," + sdr["DealerName"].ToString() + "," + sdr["DealerId"].ToString() + "," + sdr["ContactNumber"].ToString() + "," + sdr["SurveyCode"].ToString()), Encoding.UTF8));
                    data.Append("&lists=" + HttpUtility.UrlEncode(sListUri));







It is not a good idea to have commas in your list name as it can cause some issues with content in the UI and with the API.  The reasoning is because of the way CSV's are built and parsed. 

Ryan Davis
Quality Engineer

Actually the list comes from the client. So, I have no way to control the data. If there is no way, I can replace the comma before sending the list to constant contact. Just wanted to check if there was a way to include the comma using the API.


Please advise!!



You can typically send the comma as an entity but it is not suggested.  The ideal solution is to either delete it or replace it. 

Ryan Davis
Quality Engineer
Developer Portal

View API documentation, code samples, get your API key.

Visit Page