API contact call

Highlighted
Occasional Contributor

API contact call

Hi guys,

 

I have been using the ConstantContact API to integrate with SugarCRM/SuiteCRM howeveras much as everything is working when I make a call to create/update a contact to Constant Contact API. I find its updating the contacts details but ignoring the Address,

 

I could swear blind that this was working last week. it does not cause an error and the address is being set in the payload however it just ignores the address which has been added and updates/creates the contact.

 

Cheers for the help,

1 REPLY 1
Highlighted
Occasional Participant

Re: API contact call

Hi,

You can use custom field

 

private Contact AddContactToConstantContact(DoctorDTO doctor)
{
Contact contact = GetContactByEmailAddress(doctor.EmailAddress.Trim());

if (contact == null)
{
contact = new Contact();
}

contact.Lists.Add(new ContactList() { Id = EditingList.CTCTListId, Status = Status.Active });

//add email_addresses [Required]
var emailAddress = new EmailAddress()
{
Status = Status.Active,
ConfirmStatus = ConfirmStatus.NoConfirmationRequired,
EmailAddr = doctor.EmailAddress
};

contact.FirstName = doctor.FirstName == null ? string.Empty : doctor.FirstName;
contact.LastName = doctor.LastName == null ? string.Empty : doctor.LastName;

contact.WorkPhone = doctor.WorkPhone == null ? string.Empty : doctor.WorkPhone;
contact.HomePhone = doctor.MainPhone == null ? string.Empty : doctor.MainPhone;

contact.CustomFields = new List<CustomField>(contact.CustomFields);

contact.CustomFields.Add(new CustomField() { Value = doctor.AccountNumber != null ? doctor.AccountNumber : "", Name = "CustomField1" });
contact.CustomFields.Add(new CustomField() { Value = doctor.Address1 != null ? doctor.Address1 : "", Name = "CustomField2" });
contact.CustomFields.Add(new CustomField() { Value = doctor.Address2 != null ? doctor.Address2 : "", Name = "CustomField3" });
contact.CustomFields.Add(new CustomField() { Value = doctor.City != null ? doctor.City : "", Name = "CustomField4" });
contact.CustomFields.Add(new CustomField() { Value = doctor.State != null ? doctor.State : "", Name = "CustomField5" });
contact.CustomFields.Add(new CustomField() { Value = doctor.ZipCode != null ? doctor.ZipCode : "", Name = "CustomField6" });
contact.CustomFields.Add(new CustomField() { Value = doctor.PracticeGroupName != null ? doctor.PracticeGroupName : "", Name = "CustomField7" });
contact.CustomFields.Add(new CustomField() { Value = doctor.PracticeName != null ? doctor.PracticeName : "", Name = "CustomField8" });
contact.CustomFields.Add(new CustomField() { Value = doctor.CurrentCharges.ToString(), Name = "CustomField9" });
contact.CustomFields.Add(new CustomField() { Value = doctor.PastDue30.ToString(), Name = "CustomField10" });
contact.CustomFields.Add(new CustomField() { Value = doctor.PastDue60.ToString(), Name = "CustomField11" });
contact.CustomFields.Add(new CustomField() { Value = doctor.PastDue90.ToString(), Name = "CustomField12" });
contact.CustomFields.Add(new CustomField() { Value = doctor.PastDue120.ToString(), Name = "CustomField13" });
contact.CustomFields.Add(new CustomField() { Value = doctor.PastDue150.ToString(), Name = "CustomField14" });
contact.CustomFields.Add(new CustomField() { Value = doctor.PastDue180.ToString(), Name = "CustomField15" });

//update Contact if Id exists in constant contact
if (contact.Id != null)
{
return contact = _constantContact.ConstantContact.UpdateContact(contact, false);
}
else
{
contact.EmailAddresses.Add(emailAddress);
return contact = _constantContact.ConstantContact.AddContact(contact, false);
}
}

 

Thank you

Raj

raj_gaurav@outlook.com

Developer Portal

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

Visit Page

Constant Contact Would Like To Hear From You!

We want to hear from customers like you about your favorite features and how they have helped your business or organization. Tell us by answering a few questions in...

Read More
Featured