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>
Best Answer
The following solution seems to be working for me.
Thanks Kelly and Brodrick from ET for help.