3

Using the Fuel PHP SDK I can add rows one at a time to my Data Extension. However, I cannot figure out how to add multiple rows in one call. Is it possible?

As I need to add between 5 and 5000 rows to a Data Extension, the overhead of adding each individually seems crazy, while the number of rows involved don't justify the complexity of a SFTP upload and a triggered import.

I have checked the Java, C#, Ruby & Python SDKs and none have an example of adding multiple rows; however the REST API (and structure of the SOAP payload) make me think this should be possible.

1

I'm not familiar enough with the PHP SDK to tell you the correct syntax. But, I have confirmed you can make a single API call to upsert multiple rows in a data extension. The syntax of the soap envelope looks something like this.

<UpdateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
    <Options>
        <SaveOptions>
            <SaveOption>
                <PropertyName>*</PropertyName>
                <SaveAction>UpdateAdd</SaveAction>
            </SaveOption>
        </SaveOptions>
    </Options>
    <Objects xsi:type="DataExtensionObject">
        <PartnerKey xsi:nil="true"/>
        <ObjectID xsi:nil="true"/>
        <CustomerKey>SomeDataExtensionKey</CustomerKey>
        <Properties>
            <Property><Name>keyfield</Name><Value>keyvalue1</Value></Property>
            <Property><Name>field2</Name><Value>data1</Value></Property>               
        </Properties>
        <Properties>
            <Property><Name>keyfield</Name><Value>keyvalue2</Value></Property>
            <Property><Name>field2</Name><Value>data2</Value></Property>               
        </Properties>                
        <Properties>
            <Property><Name>keyfield</Name><Value>keyvalue3</Value></Property>
            <Property><Name>field2</Name><Value>data3</Value></Property>               
        </Properties>                
    </Objects>
</UpdateRequest>

I hope this helps.

| improve this answer | |
  • I tested this and found this is not working. Thanks – sf_user Apr 16 '17 at 6:43
1

To add rows, CreateRequest can be used.

<CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
                <Objects xsi:type="DataExtensionObject">
                     <CustomerKey>TestDE</CustomerKey>
                     <Properties>
                          <Property>
                               <Name>Nickname</Name>
                               <Value>test1</Value>
                            </Property>
                        <Property>
                              <Name>Amount</Name>
                           <Value>7100</Value>
                        </Property>
                </Properties>
             </Objects>
             <Objects xsi:type="DataExtensionObject">
                     <CustomerKey>TestDE</CustomerKey>
                <Properties>
                          <Property>
                               <Name>Nickname</Name>
                               <Value>test2</Value>
                            </Property>
                        <Property>
                              <Name>Amount</Name>
                           <Value>8100</Value>
                        </Property>
                </Properties>
             </Objects>
    </CreateRequest>
| improve this answer | |
0

The answer is to create multiple "Objects".

SOAP Envelope (within "CreateRequest":

<Objects xsi:type="DataExtensionObject">
    <CustomerKey>MY_DE/CustomerKey>
    <Properties>
       <Property>
          <Name>hey</Name>
          <Value>hi</Value>
       </Property>
    </Properties>
 </Objects>
 <Objects xsi:type="DataExtensionObject">
    <CustomerKey>MY_DE</CustomerKey>
    <Properties>
       <Property>
          <Name>hey</Name>
          <Value>yo</Value>
       </Property>
    </Properties>
 </Objects>

SOAP PHP SDK

// Storing as an array will allow you to insert multiple rows in one call
$cr = new ExactTarget_CreateRequest();
$cr.Objects = array();
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.