1

I'm having a hard time finding sample code that will allow me to update a record on a DE. I was able to successfully add new records with 3 fields: email (primary key), fname, lname. However, when I attempt to send a new payload with the same email address (new fname), I get this error: Violation of PRIMARY KEY constraint...which makes total sense. How do I go about updating an existing record?

This is the payload I am attempting, but get "Bad Request" as the response.

<s:Bodyxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<UpdateRequestxmlns="http://exacttarget.com/wsdl/partnerAPI">
            <Options>
            </Options>
<Objectsxsi:type="DataExtensionObject">
                  <PartnerKey xsi:nil="true">
                  </PartnerKey>
                  <ObjectID xsi:nil="true">
                  </ObjectID>
                  <CustomerKey>AF7DC4B3</CustomerKey>
                  <Properties>
                       
                        <Property>
                              <Name>EmailAddress</Name>
                              <Value>[email protected]</Value>
                        </Property>
                        <Property>
                              <Name>FirstName</Name>
                              <Value>Angel</Value>
                        </Property>
                        <Property>
                              <Name>LastName</Name>
                              <Value>Cruz</Value>
                        </Property>
                  </Properties>
            </Objects>
</UpdateRequest>
</s:Body>
0

1 Answer 1

0

To update a record in a DE aside from the fact that this DE needs to have a primary key field, you would need to specify the Options part

For example, I would use something like:

  <Options>
    <SaveOptions>
      <SaveOption>
        <PropertyName>EmailAddress</PropertyName>
        <SaveAction>UpdateOnly</SaveAction>
      </SaveOption>
    </SaveOptions>
  </Options>

You can get more properties for "SaveAction" here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .