6

I am retrieving data from a data extension using RetrieveRequest. Following is a snippet of my approach:

RetrieveRequest retrieveRequest = new RetrieveRequest();
retrieveRequest.setObjectType(dataExtensionId);
String[] properties = new String[]{"hospital_long_name", "hospital_address", "client_name", "email_address"};
    for(String property : properties) {
       retrieveRequest.getProperties().add(property);
    }

RetrieveRequestMsg reqMessage = new RetrieveRequestMsg();
reqMessage.setRetrieveRequest(retrieveRequest);
RetrieveResponseMsg resMessage = exactTargetService.retrieve(reqMessage);

With the above approach, as you can see I am only able to retrieve 4 properties from my data extension. i.e ("hospital_long_name", "hospital_address", "client_name", "email_address") I checked the documentation and I was unable to find a method through which I could just fetch all of the columns in a data extension without mentioning them explicitly in my request call.

Thanks for any suggestion.

Based on Kelly's suggestion , I tried something like this:

RetrieveRequest request = new RetrieveRequest();
request.setObjectType("DataExtensionObject[DE_" +key+"]");
SimpleFilterPart filterPart = new SimpleFilterPart();
filterPart.setProperty("CustomerKey");
SimpleOperators operand = SimpleOperators.EQUALS;
filterPart.setSimpleOperator(operand);
filterPart.getValue().add("DE_"+key);
request.setFilter(filterPart);  
RetrieveRequestMsg reqMessage = new RetrieveRequestMsg();
reqMessage.setRetrieveRequest(request);
RetrieveResponseMsg resMessage = exactTargetService.retrieve(reqMessage);

But it gave me an error saying "Object reference not set to an instance of an object". Am I doing something wrong here?

Following is the SOAP request envelope. (Only Body Part):

<soap:Body>
    <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI"
        xmlns:ns2="urn:fault.partner.exacttarget.com">
        <RetrieveRequest>
            <ObjectType>DataExtension</ObjectType>
            <Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:type="SimpleFilterPart">
                <Property>CustomerKey</Property>
                <SimpleOperator>equals</SimpleOperator>
                <Value>DE_Appointment_Reminder_H2882</Value>
            </Filter>
        </RetrieveRequest>
    </RetrieveRequestMsg>
</soap:Body>

Following is the SOAP response envelope (Only Body Part):

<soap:Body>
    <RetrieveResponseMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <OverallStatus>Error: Object reference not set to an instance of an
            object.</OverallStatus>
        <RequestID>f4c96918-276f-489d-84df-dea695c63383</RequestID>
    </RetrieveResponseMsg>
</soap:Body>
7
  • Are you using the java sdk, by chance? Dec 20, 2013 at 18:50
  • yes I am using java sdk
    – Ashish
    Dec 20, 2013 at 18:55
  • I did think of an easy solution, just by simply deleting the data extension and creating one. but then I went through the documentation which says you may not be able to re-create a data extension with the same name because our system keeps track of the deleted one. So obviously this is not gonna work.
    – Ashish
    Dec 20, 2013 at 19:45
  • I have no idea how to read Java :-/ Can you possibly post this as the SOAP packet? That might explain a bit more to me. Dec 21, 2013 at 2:04
  • please see the edit.
    – Ashish
    Dec 22, 2013 at 22:34

2 Answers 2

4

The following solution seems to be working for me.

    <soap:Body>
    <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI"
        xmlns:ns2="urn:fault.partner.exacttarget.com">
        <RetrieveRequest>
          <ObjectType>DataExtensionField</ObjectType>
          <Properties>Name</Properties>
          <Filter xsi:type="SimpleFilterPart" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <Property>DataExtension.CustomerKey</Property>
            <SimpleOperator>equals</SimpleOperator>
            <Value>DE_Appointment_Reminder_H2882</Value>
          </Filter>
        </RetrieveRequest>
    </RetrieveRequestMsg>
</soap:Body>

Thanks Kelly and Brodrick from ET for help.

2
  • Know that you can also (but maybe with a delay) can accept your own answer as accepted answer. This will mark the question as resolved. Dec 24, 2013 at 15:41
  • The data extension field it what I was originally suggesting to use - glad you were able to get it worked out. Dec 24, 2013 at 18:15
1

You should be able to retrieve all of the field names, filtering by the customer key of the data extension.

Here is the documentation on the object http://help.exacttarget.com/en/technical_library/web_service_guide/objects/dataextensionfield/

2
  • thanks for your answer, I did try this. please see the edit on my original question
    – Ashish
    Dec 20, 2013 at 21:07
  • this link help.exacttarget.com/en/technical_library/web_service_guide/… says "Note that the name of the deleted data extension will not be immediately available for reuse. The application retains data extension information for an extended period of time even after the delete call to make sure current processes have access to that data." I just tried deleting and creating the same data extension and it worked. So now I am pretty confused with the statement too.
    – Ashish
    Dec 20, 2013 at 21:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .