I'm using the following code in a class in order to submit a new contact and add them to a list. I'm getting a 400 error which I understand to be xml problems most of the time. However, I can't seem to figure out how to grab the xml that's being sent. I know that my authentication is working as I can faithfully break that and get a differeny error.
I've just starting working with this API and we have a client that is being somewhat urgent in getting this up and running.
Any help is appreciated.
The code bombs out on line 1728 of Utility.cs.
var ccContact = new Contact();
ccContact.CustomField1 = Server.HtmlEncode(ddOrgTypes.SelectedValue);
ccContact.CountryCode = Server.HtmlEncode(ddCountries.SelectedValue);
ccContact.FirstName = Server.HtmlEncode(txtFirstName.Text);
ccContact.LastName = Server.HtmlEncode(txtLastName.Text);
ccContact.EmailAddress = Server.HtmlEncode(txtEmailAddress.Text);
ccContact.JobTitle = Server.HtmlEncode(txtJobTitle.Text);
ContactOptInList contactOptInList = new ContactOptInList();
contactOptInList.ContactList = new ContactList("General Interest");
contactOptInList.ContactList = new ContactList("EmailList");
var ccAuth = new AuthenticationData(CcApiKey, CcUsername, CcPassword);
PRoblem is the ContactList options you are setting, they must be the ID number value of the lists in question. Check out this post for how you would want to creat them. developer.constantcontact.com/node/2033
It's also worth mentioning that this should be throwing an exception with a full detailed message of the error. If you put the Utility.CreateNewContact() method in a try/catch block you will be able to catch the exception and get the full error details.
Hope this helps!
View API documentation, code samples, get your API key.Visit Page
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