2

How can we fetch the properties of a Marketing cloud Data Extention using it's API. For Example :- there is a Data extention named "ABC" and having feilds(properties) like name(String), age(integer), etc.

I want to fetch the properties of Data Extention with it's data type via API so that I have the information that the DE "ABC" has properties name,age,etc with data type String,integer,etc respectively.

1

You can do a SOAP Post call leveraging DataExtensionField object.

The SOAPAction should be "Retrieve"

The payload should be something similar to:

<?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>
      <fueloauth xmlns="http://exacttarget.com">{{access_token}}</fueloauth>
   </s:Header>
   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
                     <RetrieveRequest>
                        <ObjectType>DataExtensionField</ObjectType>
                        <Properties>FieldType</Properties>
                        <Properties>Name</Properties>
                        <Properties>IsRequired</Properties>
                        <Properties>Scale</Properties>  
                        <Filter xsi:type="SimpleFilterPart">
                           <Property>DataExtension.CustomerKey</Property>
                           <SimpleOperator>equals</SimpleOperator>
                           <Value>DE_CUSTOMER_KEY</Value>
                        </Filter>
                     </RetrieveRequest>
                  </RetrieveRequestMsg>  
   </s:Body>
</s:Envelope>

You can get use more properties on your payload to get more information about your fields, like:

<Properties>DefaultValue</Properties>
<Properties>MaxLength</Properties>
<Properties>CreatedDate</Properties>

More properties to be found in the link to the DataExtensionField documentation provided above.

PS: Don't forget to add data_extensions_read scope to your authentication payload, and to your package on Marketing Cloud as well.

For a step by step guide, checkout Gregory's latest article: Introduction to making API calls to SFMC from POSTman

  • Im using the same code but it is giving me error when using by SOAPUI tool:- <soap:Body> <soap:Fault> <faultcode>soap:Client</faultcode> <faultstring>Server was unable to read request. ---> There is an error in the XML document. ---> Input string was not in a correct format.</faultstring> <detail/> </soap:Fault> </soap:Body> – Jitesh Goel Dec 21 '19 at 16:22
  • Did you change the {{access_token}} in the payload with your access token? – Rachid Mamai Dec 21 '19 at 16:30
  • yes, I fetched the access token from my MC org using the /V2/token request API – Jitesh Goel Dec 21 '19 at 16:33
  • Did you change the DE_CUSTOMER_KEY as well? I have just tested the payload above and it's working perfectly – Rachid Mamai Dec 21 '19 at 16:38
  • yes I did change the key as per the DE – Jitesh Goel Dec 24 '19 at 16:45

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.