I’m using my new API key. It’s very simple C# code. It never adds the contact. No error message either. Anybody know what might be wrong here? See the code below.
string TableName = “UserDetails”;
string FirstName = this.FirstNameTextBox.Text;
string LastName = this.LastNameTextBox.Text;
string _HeardAboutUs = iHeardAboutUsThrough;
string CompanyName = this.txtCompanyName.Text;
string SearchEngineValue = SearchEngineTerm;
string NumberOfAdvisors = this.drpAdviserTeamCount.Text;
string Email = UserName;
string PhoneNum = “None”;
string _AdvisorOrIndividual = UserVersion;
string _IsFreeTrial = “Yes”;
//string IPAddress = IPAddress;
DateTime tempdate = DateTime.Now;
string stringdate = DateTime.Now.ToString(“yyyyMMdd”);
var xmlContent = "<?xml version='1.0' encoding='UTF-8'?>\r\n<methodCall>\r\n "
//+"<methodName>ContactService.addToGroup</methodName>\r\n "
+ "<methodName>ContactService.add</methodName>\\r\\n "
+ "<params>\r\n "
+ " <param>\r\n <value><string>" + key + "</string></value>\r\n </param>\r\n "
+ " <param>\r\n <value><int>" + TableName + "</int></value>\r\n </param>\r\n "
+ "<param>\r\n <value><struct>\r\n "
+ "<member><name>FirstName</name>\r\n <value><string>" + FirstName + "</string></value>\r\n </member>\r\n "
+ "<member><name>LastName</name>\r\n <value><string>" + LastName + "</string></value>\r\n </member>\r\n "
+ "<member><name>_HeardAboutUs</name>\r\n <value><string>" + _HeardAboutUs + "</string></value>\r\n </member>\r\n "
+ "<member><name>Company</name>\r\n <value><string>" + CompanyName + "</string></value>\r\n </member>\r\n "
+ "<member><name>_SearchEngineTerm</name>\r\n <value><string>" + SearchEngineValue + "</string></value>\r\n </member>\r\n "
+ "<member><name>_NumberOfAdvisors</name>\r\n <value><string>" + NumberOfAdvisors + "</string></value>\r\n </member>\r\n "
+ "<member><name>Email</name>\r\n <value><string>" + Email + "</string></value>\r\n </member>\r\n "
+ "<member><name>Phone1</name>\r\n <value><string>" + PhoneNumber + "</string></value>\r\n </member>\r\n "
+ "<member><name>_AdvisorOrIndividual0</name>\r\n <value><string>" + _AdvisorOrIndividual + "</string></value>\r\n </member>\r\n "
+ "<member><name>_IsFreeTrial4</name>\r\n <value><string>" + _IsFreeTrial + "</string></value>\r\n </member>\r\n "
+ "<member><name>_IPAddress2</name>\r\n <value><string>" + IPAddress + "</string></value>\r\n </member>\r\n "
+ "<member><name>_TrialStartDate1</name>\r\n <value><string>" + stringdate + "</string></value>\r\n </member>\r\n "
+ " \r\n </struct></value> </param>\r\n "
+ "</params>\r\n</methodCall>\r\n\r\n";
var content = new StringContent(xmlContent, null, "application/xml");
request.Content = content;
var task = Task.Run(async () =>
{
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
string responseContent = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseContent);
});
task.GetAwaiter().GetResult(); // Blocking call to wait for task completion