Skip Navigation
Expand
A "Duplicate key" error is thrown when attempting to add a phone number to a contact
Answer ID 7093   |   Last Review Date 09/23/2018

Why is a 'Duplicate key...' error returned when adding a phone number to a contact using the Connect Web Services for SOAP API?

Environment:

Connect Web Services for SOAP

Issue:

The following error is returned when I attempt to add a phone number to a contact using the Connect Web Services for SOAP API.

"Duplicate key: An item with identical key(s) is present in the list; Contact(ID={ID}).Phones"

Resolution:

Use the "update" action, rather than the "add" action, for the phone number you are attempting to add. This is demonstrated in the following snippet from a SOAP Envelope.

<ns4:PhoneList action="update">
  <ns4:Number>d (ddd) ddd-dddd</ns4:Number>
  <ns4:PhoneType>
      <ID id="4" />
  </ns4:PhoneType>
</ns4:PhoneList>

Cause:

The type of phone number you are attempting to add (such as a "Home Phone" or an "Office Phone") has already been added to the contact. Only a single number can be added for a given type of phone number.