I'm testing sending transactional email through the Exact Target API and the Fuel SDK for PHP. I've successfully sent a test email but I don't appear to be able to send a second email to the same address as I get the following error from the API
[ErrorCode] => TriggeredSendSubscriberProcessingError [ErrorDescription] => Error Code: 21 - Cannot insert duplicate row into data extension for subscriber 21.
The code used is fairly similar to the Fuel SDK example code
$sendTrigger = new ET_TriggeredSend(); $sendTrigger->props = array('CustomerKey' => 'test'); $sendTrigger->authStub = $myclient; $sendTrigger->subscribers = array(array( "EmailAddress" => "email@example.com", "SubscriberKey" => "firstname.lastname@example.org", "Attributes" => array( array('Name' => 'MemberEmailAddress', 'Value' => 'email@example.com'), array('Name' => 'MemberFirstName', 'Value' => 'Firstname'), array('Name' => 'MemberLastName', 'Value' => 'Lastname'), array('Name' => 'ActivationLink', 'Value' => 'http://www.example.com.au/test-verify') ) )); $sendResult = $sendTrigger->send();
The data extension has the following fields
SubscriberKey Text 100
EmailAddress EmailAddress 100
MemberEmailAddress EmailAddress 100 Primary Key
MemberFirstName Text 255
MemberLastName Text 255
ActivationLink Text 512
The data extension appears to require me to set a primary key that is not one of the inherited template fields,
EmailAddress. I suspect the current primary key
MemberEmailAddress is what is causing the error when subsequent calls to the API are trying to insert extra records into the DE and clashing with previous records.
Should I just be using a numeric 'id' field or similar for the primary key instead?