1

My requirement is to retrieve all the data for Exact Target objects.

The Fuel SDK supports retrieval of data using both REST as well as SOAP apis. The REST api has pagination support so for objects like Campaigns, Assets that are REST based we can retrieve data in smaller chunks for bulk extraction. Is there a way to do the same for objects that use the SOAP API like Email, Subscriber, etc.?

  • you had the answers on this issue? I have the same need I am using the JAVA FuelSDK. The response class ETResponse retrieve only first 2500 records Can you tell me how you solved ? Thanks – Michele Dec 29 '15 at 11:16
  • I just posted my answer. Do mark it as the correct answer if this works for you. – Piyush Khera Dec 30 '15 at 12:48
0

Marketing Cloud SOAP API does not support pagination. The default batch is 2500 records at a time and have to be retrieved serially.

  • Thanks Mac. I am using the JAVA FuelSDK. The response class ETResponse does have a method ETResponse.hasMoreResults() to check if more results are available. But I could not find any method called getMoreResults() or continue() that are available in php sdk. Could you please guide me on how to retrieve records in batch using Java FuelSDK? – Piyush Khera Jun 1 '15 at 5:15
0

After going through the source code I managed to solve this by using the sdk internal classes to retrieve all pages for an object. Here is a sample code that works for me:

int page = 1;
RetrieveResponseMsg response = null;
String filterString = "<filter expression here>";
ETFilter filter = ETFilter.parse(filterString);
ETConfiguration etConf = new ETConfiguration();
etConf.set("clientId", "<client id here>");
etConf.set("clientSecret", "<client secret here>");
ETClient etClient = new ETClient(etConf);
do{

    RetrieveRequest rr = new RetrieveRequest();
    rr.setObjectType("Email");
    rr.getProperties().addAll(Arrays.asList(new String[] {"Name","PreHeader","Folder"}));

    RetrieveOptions ro = new RetrieveOptions();
    ro.setBatchSize(2);
    rr.setOptions(ro);

    if(filter != null){
        rr.setFilter(ETSoapObject.toFilterPart(filter));
    }
    RetrieveRequestMsg rrm = new RetrieveRequestMsg();
    rrm.setRetrieveRequest(rr);

    if(page > 1){
        rrm.getRetrieveRequest().setRetrieveAllSinceLastBatch(true);
    }

    response = etClient.getSoapConnection().getSoap().retrieve(rrm);
    if(!"OK".equals(response.getOverallStatus()) && !"MoreDataAvailable".equals(response.getOverallStatus())){
        throw new Exception(response.getOverallStatus(), null );
    }
    List<APIObject> results = response.getResults();
    for(APIObject apiObject : results){
        // Iterating results
    }

    page++;
}while(response != null && "MoreDataAvailable".equals(response.getOverallStatus()));

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.