V3.0 API adding contacts either JSON or CSV

FrankK144
Occasional Participant

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":"larry@ccstest.com","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":"jeff@ccstest.com","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

0 REPLIES 0
Developer Portal

View API documentation, code samples, get your API key.

Visit Page