V3.0 API adding contacts either JSON or CSV
Cannot add contacts to list using JSON
Â
Cannot using CSV either but can wait on that
Â
What am I doing wrong?
Â
Â
JSON body
Â
{"import_data":[{"email":"[email protected]","first_name":"larry","last_name":"Jones","job_title":null,"company_name":null,"anniversary":null,"birthday_month":0,"birthday_day":0,"phone":null,"street":null,"street2":null,"city":null,"state":null,"zip":null,"country":null,"cf:listid":"listone","cf:contactid":"contactthree"},{"email":"[email protected]","first_name":"Jeff","last_name":"Thompson","job_title":null,"company_name":null,"anniversary":null,"birthday_month":0,"birthday_day":0,"phone":null,"street":null,"street2":null,"city":null,"state":null,"zip":null,"country":null,"cf:listid":"listone","cf:contactid":"contactfour"}],"list_ids":["XXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"]}
Â
Response
Â
{
"activity_id" : "e2f30990-f8f5-11ea-8230-d4ae5292c4bc","state" : "initialized","created_at" : "2020-09-17T14:55:54Z","updated_at" : "2020-09-17T14:55:54Z","source_file_name" : "csv_from_json_2020-09-17T10_55_54-04_0020200917-2460-1e26sdz.csv","percent_done" : 1,"activity_errors" : [ ],"status" : { },"_links" : { "self" : { "href" : "\/v3\/activities\/e2f30990-f8f5-11ea-8230-d4ae5292c4bc"}}}
Â
((RestSharp.RestResponseBase)response).IsSuccessful true
Â
Â
Have tried through my app as well as the through the API tester
Â
The API tester returns 201 but the same response
Â
The only contact in my account is my own which was added when I created the account
Â
I am using restsharp and C# and have been able to successfully add both campaigns and lists
Â
Â
Here is the code I am using:
Â
var url = "https://api.cc.email/v3/activities/contacts_json_import/";
//create RestSharp client and POST request object
var client = new RestClient(url);
var request = new RestRequest(Method.POST);
//request headers
request.RequestFormat = DataFormat.Json;
request.AddHeader("Content-Type", "application/json");
//object containing input parameter data for DoStuff() API method
var apiInput = importdata;
string z = JsonConvert.SerializeObject(apiInput);
z = z.Replace("cflistid", "cf:listid");
z = z.Replace("cfcontactid", "cf:contactid");
//add parameters and token to request
request.Parameters.Clear();
request.AddParameter("Accept", "application/json");
request.AddParameter("application/json", z, ParameterType.RequestBody);
//request.AddParameter("application/json", JsonConvert.SerializeObject(apiInput), ParameterType.RequestBody);
request.AddParameter("Authorization", "Bearer " + tokens.AccessToken, ParameterType.HttpHeader);
//make the API request and get a response
IRestResponse response = client.Execute(request);
Â
Any insight would be appreciated