[SalesForce] How to get list of data extension fields using SOAP API

I have reviewed https://help.exacttarget.com/en/technical_library/web_service_guide/technical_articles/ and cannot find example of how to a get list of data extension fields.

If this is possible I would appreciate a sample of the SOAP envelope.

Best Answer

It's a simple retrieve on the DataExtensionField object. You can filter on DataExtension.CustomerKey if you want to view the columns for a specific Data Extension.

Here's a example SOAP envelope: https://gist.github.com/wvpv/9001b002ebf7552f64db

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   <s:Header>
      <a:Action s:mustUnderstand="1">Retrieve</a:Action>
      <a:MessageID>urn:uuid:e3f7fdfe-d225-47fb-a764-ad4f465fb724</a:MessageID>
      <a:ReplyTo>
         <a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
      </a:ReplyTo>
      <a:To s:mustUnderstand="1">https://webservice.exacttarget.com/Service.asmx</a:To>
      <o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1">
         <u:Timestamp u:Id="_0">
            <u:Created>2014-11-18T14:44:10.936Z</u:Created>
            <u:Expires>2014-11-18T14:49:10.936Z</u:Expires>
         </u:Timestamp>
         <o:UsernameToken u:Id="uuid-642de236-bbe2-41d9-b965-d107063c913c-3">
            <o:Username>
               <!-- Removed-->
            </o:Username>
            <o:Password>
               <!-- Removed-->
            </o:Password>
         </o:UsernameToken>
      </o:Security>
   </s:Header>
   <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
         <RetrieveRequest>
            <ObjectType>DataExtensionField</ObjectType>
            <Properties>Client.ID</Properties>
            <Properties>CreatedDate</Properties>
            <Properties>CustomerKey</Properties>
            <Properties>DataExtension.CustomerKey</Properties>
            <Properties>DefaultValue</Properties>
            <Properties>FieldType</Properties>
            <Properties>IsPrimaryKey</Properties>
            <Properties>IsRequired</Properties>
            <Properties>MaxLength</Properties>
            <Properties>ModifiedDate</Properties>
            <Properties>Name</Properties>
            <Properties>ObjectID</Properties>
            <Properties>Ordinal</Properties>
            <Properties>Scale</Properties>
            <Filter xsi:type="SimpleFilterPart">
               <Property>DataExtension.CustomerKey</Property>
               <SimpleOperator>equals</SimpleOperator>
               <Value>DATA EXTENSION NAME</Value>
            </Filter>
            <QueryAllAccounts>true</QueryAllAccounts>
            <Retrieves />
            <Options>
               <SaveOptions />
               <IncludeObjects>true</IncludeObjects>
            </Options>
         </RetrieveRequest>
      </RetrieveRequestMsg>
   </s:Body>
</s:Envelope>
Related Topic