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(); }
Solved! Go to Solution.
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.
Tony/Heather,
The bulk import (multipart) endpoint supports files with the following formats:
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.
Yes, precisely...my file is TAB delimited and the file extension is .CSV. It imported just fine in the CC website.
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.
The holidays have come and gone. For many seasonal businesses, this means the rush of shoppers has decreased as well. Instead of turning off the lights and waiting for spring, make your email marketi...
See Article