cancel
Showing results for 
Search instead for 
Did you mean: 
Due to an issue with YouTube, inserting videos in your emails is showing an error. Until they are able to resolve this issue, we recommend using a different video hosting service. We will continue to monitor this outage and update you as we have more information.

C# integration bulk insert and CSV files

Highlighted
Occasional Contributor

C# integration bulk insert and CSV files

What method do you use to allow commas in a field to be uploaded using the bulk upload activity from a file. 
I am using the "ContactstMultipartActivity" method and if a field has a comma in it, it push data to the next column. I tried placing "" around the field in the file but it didn't resolve the problem. 
 
Also, are excel files supported in the method above? I tried a couple of excel files, however, I get a message only 4 file types are supported, txt, cvs, xls and xlsx files. I tried 3 different spreadsheet formats in excel, with extensions xls and xlsx. 
 
Thank you.

3 REPLIES 3
Moderator

Re: C# integration bulk insert and CSV files

Hello @KarenO65,

 

I do not have C# code written to submit a multi part file; however I do have what it should look like if you use a RESTful client such as Postman. Here is a screenshot of submitting an .xlsx file.

 

multi part file post xlsx.jpg


Regards,
Jimmy D.
Tier II API Support Engineer
Occasional Contributor

Re: C# integration bulk insert and CSV files

From your Constant Contact Developer Sample Library page: https://developer.constantcontact.com/libraries/sample-code.html

There is a link to the CTCT Wrapper as a project.  https://github.com/constantcontact/.net-sdk

In that project, there is a method called:  ContactstMultipartActivity. 

I am using this to do the bulk insert from a file. 

 

Also, I tested a xlsx file with you web site import process, and it worked. When I tried it with the code it said the file was not the correct type.

 

Here is the issue with importing with CSV: The issue is that the data in columns from our database sometimes contains data. For example, some times a phone field will have a the number as 800-888-8888, 23. Some people will use a , to separate the extension from the number. Or a company name will have a comma in the field example Greg and Sons, Inc. In these two examples, is there a way to use an escape code in C# that would allow me to replace the comma in the string to another value, that would not separate the information in another column. I am writing an integration project in C# using your CTCT wrapper project to assist in the development.

 
 
Moderator

Re: C# integration bulk insert and CSV files

Hello @KarenO65,

 

We don't currently have a C# developer on staff and my skills are a bit rusty; however from what I was able to locate there are a few options when trying to escape a character in C#. I do not know which one of these options would work the best for you though.

 

You can try just the basics of escaping by adding a backslash in front of the comma. example: \, (this is the least likely to work)

 

You can try the unicode hex value. Unicode UTF-16: 002c

 

You can also try what is known as verbatim escaping where you place an @ at the beginning of the text and surround the text by " ".

 

Again I am not a C# developer; this is just information I was able to locate in an internet search so it may or may not be helpful in this situation.


Regards,
Jimmy D.
Tier II API Support Engineer