I have a long list of geographical locations which I would like to add to a campaign. I would like to read from a list of zip codes, look up the criteria ID for each one, and add them all to a campaign. The bit of python code which does the ID lookup looks like this:
def find_ids(client):
location_criterion_service = client.GetService(
'LocationCriterionService', version='v201402')
with open('zip_codes.txt') as temp_file:
location_names = [line.rstrip('\n') for line in temp_file]
selector = {
'fields': ['Id', 'LocationName'],
'predicates': [{
'field': 'LocationName',
'operator': 'IN',
'values': location_names
}, {
'field': 'Locale',
'operator': 'EQUALS',
'values': ['en']
}]
}
location_criteria = location_criterion_service.get(selector)
It works as long as the list of zip codes is no longer than 25. Any longer and it throws an error:
SizeLimitError.REQUEST_SIZE_LIMIT_EXCEEDED @ locationName; trigger:'25'
Is there a better way to do this, or do I need to set up a batching loop?
Thanks very much for any help.
- Steve Renaker