0

I am trying to retrieve records currently contained in a data extension. I have checked the documentation but couldn't typically find out how to retrieve from the extension and examples I've found online are pretty old as the sdk has been updated. What I have currently is that it retrieves all of my data extension but I only want to retrieve one of my data extension. The name of the data extension I want to retrieve is "Customer_opt". I also have the external key of the Customer_opt data extension.

This is what I have so far:

    public static void main(String[] args) throws ETSdkException {
    SpringApplication.run(SoapApplication.class, args);

    ETConfiguration configuration = new ETConfiguration();
    configuration.set("clientId", clientId);
    configuration.set("clientSecret", clientSecret);
    ETClient client = new ETClient(configuration);

    ETSoapConnection soapConnection = new ETSoapConnection(client, "https://@@@@@@@@@@.soap.marketingcloudapis.com/Service.asmx");


    ETResponse<ETDataExtension> response = client.retrieve(ETDataExtension.class);
    System.out.println(response);
}

EDIT = This is what I have and now able to query the data extension:

    public static void main(String[] args) throws ETSdkException {
    SpringApplication.run(SoapApplication.class, args);

    ETConfiguration configuration = new ETConfiguration();
    configuration.set("clientId", clientId);
    configuration.set("clientSecret", clientSecret);
    ETClient client = new ETClient(configuration);

    ETSoapConnection soapConnection = new ETSoapConnection(client, "https://@@@@@@@@.soap.marketingcloudapis.com/Service.asmx");
    ETFilter etf = new ETFilter();
    ETExpression expression = new ETExpression();
    expression.setProperty("name");
    expression.setOperator("=");
    expression.setValue("Customer_opt");
    etf.setExpression(expression);

    ETResponse<ETDataExtension> response = client.retrieve(ETDataExtension.class, etf);

    System.out.println(response);
}

BUT I've noticed that the fields do not come with the response. I've checked it with another data extension that I have and I cant seem to find the fields.

This is what the response outputs:

com.exacttarget.fuelsdk.ETResponse[
batchResult = com.exacttarget.fuelsdk.ETResult[
    status = OK
    requestId = XXXXXXXX
    responseCode = OK
    responseMessage = OK
]
individualResults = [com.exacttarget.fuelsdk.ETResult[
    object = com.exacttarget.fuelsdk.ETDataExtension[
        id = XXXXXX
        key = XXXXXX
        name = Customer_opt
        description = 
        createdDate = Fri Dec 07 06:10:07 GMT 2018
        modifiedDate = Wed Apr 24 23:47:42 BST 2019
        folderId = XXXXX
        columns = []
        isSendable = false
        isTestable = false
    ]
]]
moreResults = false

]

1

I am not sure what it is inside the SDK, but I believe you are looking at the wrong Object. 'DataExtension' is essentially all the properties and structure of the DE - not the data contained in it.

For that you would need to use the 'DataExtensionObject' Object, which represents the rowsets inside of a specific Data Extension.

A good resource for retrieving data from a data extension is the documentation. It is not SDK specific, but through this and the SDK documentation you should be able to correctly sync it up.

Sample of SOAP Envelope for DataExtensionObject:

 <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
 <RetrieveRequest>
 <ObjectType>DataExtensionObject[Example DE]</ObjectType>
 <Properties>EMAIL_ADDRESS</Properties>
 <Properties>CUSTOMER_ID</Properties>
 <Properties>FIRST_NAME</Properties>
 <Properties>SITE_GROUP</Properties>
 <Filter xsi:type="SimpleFilterPart">
 <Property>EMAIL_ADDRESS</Property>
 <SimpleOperator>equals</SimpleOperator>
 <Value>acruz@example.com</Value>
 </Filter>
 </RetrieveRequest>
 </RetrieveRequestMsg>

Which will return:

  <RetrieveResponseMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
    <OverallStatus>OK</OverallStatus>
    <RequestID>a484cd16-5cf8-4eb7-b4a1-ea2fba75f6fc</RequestID>
    <Results xsi:type="DataExtensionObject">
      <PartnerKey xsi:nil="true"/>
      <ObjectID xsi:nil="true"/>
      <Type>DataExtensionObject</Type>
      <Properties>
       <Property>
         <Name>EMAIL_ADDRESS</Name>
         <Value>acruz@example.com</Value>
       </Property>
       <Property>
         <Name>CUSTOMER_ID</Name>
         <Value>11111</Value>
       </Property>
       <Property>
         <Name>FIRST_NAME</Name>
         <Value>A</Value>
       </Property>
       <Property>
         <Name>SITE_GROUP</Name>
         <Value>22222</Value>
       </Property>
      </Properties>
    </Results>      
   </RetrieveResponseMsg>
  • 1
    Managed to get it working. Turns out what I had was correct but needed to use the select() method on the ETDataExtension object to get the results. – jwhefbhjebfhjew Apr 29 at 11:35

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.