[SalesForce] Retrieving folders and subfolders of an ExactTarget Data Extension with SOAP

We are retrieving the available Data Extensions in an account using the SOAP request:

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
        <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <wsse:UsernameToken wsu:Id="UsernameToken-32259181" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                <wsse:Username>username</wsse:Username>
                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
            </wsse:UsernameToken>
        </wsse:Security>
    </soapenv:Header>
    <soapenv:Body>
        <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
            <RetrieveRequest>
                <ObjectType>DataExtension</ObjectType>
                <Properties>CustomerKey</Properties>
                <Properties>Name</Properties>
            </RetrieveRequest>
        </RetrieveRequestMsg>
    </soapenv:Body>
</soapenv:Envelope>

This works fine. However, I would like to retrieve the folder and subfolder to each Data Extension as it appears in ExactTarget:

data extension folders

That is, for each Data Extension I want to build a breadcrumb trail to the Data Extension like:

Star > 202546_Star-MemberSurvey > NameOfDataExtension

I've checked the Data Extension Objects and note that there is a CategoryID property which looks like it could be related to the folder that the DE resides in, but I'm not sure how to get the name of the folder or retrieve a parent folder.

Best Answer

you can request "ParentFolder.ID and "ParentFolder.Name" as properties in your DataFolder RetrieveRequest. With that information, you can use recursive logic to match up ParentFolder.ID to ID and rebuild your DataFolder paths.