cancel
Showing results for 
Search instead for 
Did you mean: 
Tomorrow morning (8/26) from 07:00 AM - 08:00 AM ET we need to make a few updates to our site. During this time, no emails will be sent and some customers will not be able to access their contacts. We recommend finishing up your work before 07:00 AM and logging in after 08:00 AM ET. Thank you for your patience while we make these updates.

Bulk import CSV with TAB delimiters

SOLVED
Occasional Contributor

Bulk import CSV with TAB delimiters

Hi,

I'm using a C# program with the .NET SDK to bulk import our tab delimited CSV data.  I'm getting a error stating that the file is not the correct format.  The program throws an exception in the following API call.  I've imported the same CSV file with the Constant Contact website with no problems.  Any ideas as to what is going wrong?

 

Thanks,

Tony Green

Snohomish Flying Service

 

 

public Activity AddContactstMultipartActivity(string accessToken, string apiKey, string fileName, byte[] fileContent, IList<string> lists)
        {
            Activity activity = null;
            string url = String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.AddContactsActivity);
            byte[] data = MultipartBuilder.CreateMultipartContent(fileName, fileContent, lists);
            CUrlResponse response = RestClient.PostMultipart(url, accessToken, apiKey, data);

            if (response.IsError)
            {
                throw new CtctException(response.GetErrorMessage());
            }

 

 

static int Main(string[] args)
{
    ConstantContact constantContact = new ConstantContact(APIKEY, ACCESSTOKEN);
 
    string filename = FILEPATH + FILENAME;
    FileInfo fi = new FileInfo(filename);
 
    // Add XLS file contacts to "TESTING" list - 1660588414
    byte[] contents;
    using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
    {
        contents = new byte[fs.Length - 1];
        fs.Read(contents, 0, contents.Length);
        //string data = Encoding.Default.GetString(contents);
    }
 
    Activity activity = constantContact.AddContactsMultipartActivity(fi.Name, contents, new List<string> { TESTINGLIST });
    if (activity.Status == null)
    {
        Console.WriteLine("Contact Count: " + activity.ContactCount);
        Console.WriteLine("Error Count: " + activity.ErrorCount);
        Console.WriteLine();
    }
    else
    {
        Console.WriteLine("Status: " + activity.Status);
        Console.WriteLine(activity.Errors.ToString());
        Console.WriteLine();
    }
Tags (4)
3 REPLIES 3
Moderator

Re: Bulk import CSV with TAB delimiters

Tony/Heather,

 

The bulk import (multipart) endpoint supports files with the following formats:

  • txt
  • csv
  • xls
  • xlsx

You said you're working with a tab-delimited CSV file. I believe a file is either tab delimited, or comma separated, but not both. 

 

The full documentation is available here.

Rich Marcucella
Sr. Technical Writer, Content Developer
Web Services Team
http://developer.constantcontact.com
Highlighted
Occasional Contributor

Re: Bulk import CSV with TAB delimiters

Yes, precisely...my file is TAB delimited and the file extension is .CSV.  It imported just fine in the CC website.

Moderator

Re: Bulk import CSV with TAB delimiters

Checked our code and the API currently does not support tab seperated values.  We are investigating if our new contact management system still supports TSV and, if so, we will look into adding support for that format going forward.  This is not something we would likely add in the short term.

 

Our recommendation is to use the CSV file format instead.  Will update when we find out if TSV formats should be expected to work going forward.

Dave Berard
Senior Product Manager, Constant Contact