I need to upload near 40,000 contacts from our database to your. I understand that you cannot have a file over 20k records, so I have broken this up into two files. but now that I have the files, I am struggling on getting the HTTP post request setup to send the files to you. Can you give me a hand with this?
Thanks,
rg
Hello,
Thank you for reaching out to the API Support team here at Constant Contact. I'd be happy to help with what I can. I have a few questions for you:
I also want to mention that you can now import up to 40,000 contacts in a single file, up to 4mb in size.
Sincerely,
David B.
API Support Engineer
David,
I had not gotten that far yet. I was unsure how to the the post request using the file, so I changed it to a json object, but my serializer is running out of memory with 20K records...(string Jsonized = JsonConvert.SerializeObject(contacts);), so I am going to have to cut down on the record count to get it through this part to the http request.
my plan is to create a post request to your endpoint directly, and I have no affinity to using files or a json payload. I was just wondering if you had an example of a post request with a file...
thanks,
rg
so I have gotten past the json hurdle for the time being and I am trying to send just one contact and am getting a: The remote server returned an error: (400) Bad Request.
here is the json string: "[{\"Custom_Fields\":[{\"name\":\"CustomField1\",\"value\":\"\"},{\"name\":\"CustomField2\",\"value\":\"\"},{\"name\":\"CustomField3\",\"value\":\"0\"},{\"name\":\"CustomField4\",\"value\":\"0\"},{\"name\":\"CustomField5\",\"value\":\"1\"}],\"Home_Phone\":\"\",\"Work_Phone\":\"\",\"Cell_Phone\":\"\",\"First_Name\":\"Botana\",\"Last_Name\":null,\"Lists\":[],\"Email_Addresses\":[{\"Opt_In_Source\":\"ACTION_BY_OWNER\",\"Email_Address\":\"zstuff@mac.com\"}],\"Addresses\":[{\"Address_type\":\"Personal\",\"City\":\"Los Angeles\",\"Country_Code\":\"US\",\"Id\":\"1\",\"Line1\":\"1188 S. Longwood Ave.\",\"Line2\":\"\",\"Postal_Code\":\"90019\",\"State\":\"CA\",\"State_Code\":\"CA\"}]}]"
Hello,
It should be noted that this endpoint and method you are using is for sending an individual contact. If you are trying to send multiple contacts, the payload will be different. For the full documentation on our bulk endpoint, see https://developer.constantcontact.com/docs/bulk_activities_api/bulk-activities-import-contacts.html
Assuming that the slashes are simply escaping the quotation marks in your JSON from C#, here's what I see:
Here is an example of a call to that endpoint:
POST https://api.constantcontact.com/v2/contacts?action_by=ACTION_BY_OWNER&api_key=xxxxxxxx
Headers:
Content-Type : application/json
Authorization : Bearer xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Body:
{
"addresses": [
{
"address_type": "PERSONAL",
"city": "Los Angeles",
"country_code": "US",
"line1": "1188 Anywhere Ave.",
"line2": "",
"postal_code": "12345",
"state_code": "CA"
}
],
"lists": [
{
"id": "1"
}
],
"cell_phone": "",
"email_addresses": [
{
"email_address": "xxxxx@xxxxx.com"
}
],
"home_phone": "",
"work_phone": "",
"first_name": "Joe",
"last_name": "Smith",
"custom_fields": [
{
"name": "CustomField3",
"value": "0"
}, {
"name": "CustomField4",
"value": "0"
}, {
"name": "CustomField5",
"value": "1"
}
]
}
Sincerely,
David B.
API Support Engineer