I am trying to return all the data extensions within my org, and within the same script return a list from all the columns by looping through the results of from step 1.

Here is a sample of my code:

import ET_Client

    debug = False
    stubObj = ET_Client.ET_Client(False, debug)

    # Get all of the DataExtensions in an Account - This works
    print('>>> Get all of the DataExtensions in an Account')
    de = ET_Client.ET_DataExtension()
    de.auth_stub = stubObj
    de.props = ["CustomerKey"]
    de.search_filter = {'Property' : 'IsSendable','SimpleOperator' : 'equals','Value' : 'True'}
    getResponse = de.get()
    #de.search_filter = {'Property' : 'IsSendable','SimpleOperator' : 'equals','Value' : 'True'}

    extract = getResponse.results

    list2 = []

    for item in extract:


    # list2 now has all my customers keys , which I pass to a Second API Call
    for x in list2:
        de_columns = ET_Client.ET_DataExtension_Column()
        de_columns.props = ["CustomerKey"]
        de_columns.search_filter = {'Property' : 'CustomerKey','SimpleOperator' : 'equals','Value' : x}
        getResponse2 = de_columns.get()

except Exception as e:
    print('Caught exception: ' + str(e.message))

It works until I try looping the results of the second API and I get this error:

File "GetAllDEs.py", line 45, in getResponse2 = de_columns.get() File "/anaconda/lib/python3.6/site-packages/FuelSDK/objects.py", line 234, in get obj = ET_Get(self.auth_stub, self.obj, self.props, self.search_filter) File "/anaconda/lib/python3.6/site-packages/FuelSDK/rest.py", line 145, in init auth_stub.refresh_token() AttributeError: 'NoneType' object has no attribute 'refresh_token'

Not sure where to go from here. I will appreciate any pointers on this.

1 Answer 1


Here's Django management command script that queries data extensions and their columns. You can remove the Django parts. Perhaps your column search filter should use the 'like' operator instead of 'equals'.

from django.core.management.base import BaseCommand
from FuelSDK import ET_Client, ET_DataExtension, ET_DataExtension_Column

class Command(BaseCommand):
    help = 'Queries data extensions (including columns) per Business Unit from Marketing Cloud'
    client_id = 'xxxx'
    clientsecret = 'xxxxx'

    def add_arguments(self, parser):

    def handle(self, *args, **options):
            stub_obj = ET_Client(False, False, params={'clientid': client_id,
                                                   'clientsecret': client_secret})
            de = ET_DataExtension()
            de.auth_stub = stub_obj
            de.props = ["CustomerKey","Name"]
            de.search_filter = {'Property': 'Name', 'SimpleOperator': 'like', 'Value': 'test'}
            de_res = de.get()

            de_list = []
            for ext in de_res.results:

            # query for the columns
            for x in de_list:
                stub_obj = ET_Client(False, False, params={
                                     'clientid': client_id,
                                     'clientsecret': client_secret})
                de_col_req = ET_DataExtension_Column()
                de_col_req.auth_stub = stub_obj
                de_col_req.props = ["CustomerKey"]
                de_col_req.search_filter = {'Property': 'CustomerKey',
                                        'SimpleOperator': 'like',
                                        'Value': x}
                de_col_res = de_col_req.get()
                de_cols_added = []
                for res_item in de_col_res.results:

        except Exception as e:

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.