cancel
Showing results for 
Search instead for 
Did you mean: 

SDK addContact error: http.status.conflict:There was a conflict between the supplied data ...

SOLVED
Occasional Contributor

SDK addContact error: http.status.conflict:There was a conflict between the supplied data ...

Error full text: "http.status.conflict:There was a conflict between the supplied data and the existing resource"

 

I'm using the C# SDK downloaded from github. No problems getting it all set up, but when I use addContact to try an add a contact, I get an Exception with the above message. 

 

Here is the section of code that creates the contact object and callls the addContact() method:

 

var contactService = _constantContactFactory.CreateContactService();

Address address = setAddress(contactRec); 

List<EmailAddress> emails = setEmails(contactRec); 
List<ContactList> contactLists = setLists(lists); 
List<CustomField> cfields = setCustomFields(contactRec);

 

Contact contact = new Contact()
{
    EmailAddresses = emails,
    FirstName = contactRec.Name,
    CompanyName = contactRec.Company,
    WorkPhone = contactRec.Phone,
    Addresses = new List<Address> { address },
    Fax = contactRec.Fax,
    Status = "ACTIVE",
    Lists = contactLists,
    CustomFields = cfields
};

contactService.AddContact(contact, false);     // Throws the exception!

 

I've fixed other formatting errors (It didn't like my custom field names, address needed a type, etc), but I can't get the contact to save!

 

 

6 REPLIES 6
Moderator

Re: SDK addContact error: http.status.conflict:There was a conflict between the supplied data ...

Hello,

 

Thank you for reaching out to the API Support team here at Constant Contact.

 

That error typically means that you are trying to create a new contact with an email address that already exists on another contact. Our system will not let you do this, even if the contact was previously deleted (A contact is never completely deleted from within the Constant Contact account, it's simply removed). You would need to update the existing contact instead. The recommended process is to first do a GET to see if a contact exists with that email address, and then PUT to any existing returned contact, otherwise POST a new one.

 

There are methods for each of these steps within our C# SDK as well. Here is an example of how this might look using it:

https://github.com/constantcontact/.net-sdk/blob/b74bdcdc9426898219467e8fcc37b5c15bb7c84d/ContactExa...


Please let me know if you have any other questions!

 

Regards,
David B.
Tier II API Support Engineer

Highlighted
Occasional Contributor

Re: SDK addContact error: http.status.conflict:There was a conflict between the supplied data ...

Thank you for your extremely prompt response. I do actually check to see if the email exists:Currently the function below, checkContactExists(), is returning an empty ID, this triggers a call to the createContact() routine in the calling program. (I haven't tried the update yet:!)

 

 

public string CheckContactExists(IExternalContactManagement contactRec)
{
    var contactService = _constantContactFactory.CreateContactService();
    ResultSet<Contact> contacts = contactService.GetContacts(contactRec.Email, 1, null, null);
    string id = contacts.Results.Count == 0 ? "" : contacts.Results.First().Id;

    return id;
}

 

Is this wrong?

 

Also using the API tester (https://constantcontact.mashery.com/io-docs) I can't find the email address I'm trying to create, whereas I can successfully find other email addresses.

Moderator

Re: SDK addContact error: http.status.conflict:There was a conflict between the supplied data ...

Hi,

 

I'd like to do a bit more detailed investigating on this. Please email webservices(at)constantcontact.com and include your API Key, Constant Contact username, the most recent date/time you saw this response, and the details of the contact you're trying to create.

 

Regards,
David B.
Tier II API Support Engineer

Occasional Contributor

Re: SDK addContact error: http.status.conflict:There was a conflict between the supplied data ...

Hi David,

 

Just checking you got the data I sent over on Friday?

Moderator

Re: SDK addContact error: http.status.conflict:There was a conflict between the supplied data ...

Hello,

 

It doesn't appear we did. I have sent you a direct message here on the forums.

 

Sincerely,
David B.
Tier II API Support Engineer

Occasional Contributor

Re: SDK addContact error: http.status.conflict:There was a conflict between the supplied data ...

Ok, after exchanging PMs with David I can confirm that the issue is now solved. I'll post this public reply in case others have a similar problem.

 

David was on the right lines when he said 'Duplicate', however it wasn't a duplicate contact. I was trying to create a record with custom fields, and I had two called 'CustomField1'. Unsurprisingly the system didn't like it, hence the rejection.

 

I feel a bit of a fool as I should have found this out for myself, so if anyone else has a similar error - check all your field names and make sure they're all unique.