I am trying to get the “city” property for all emails, but it never shows up in my result dictionary. Any idea for what needs to be added or modified?
import requests
import json
import urllib
max_results = 50
hapikey = 'XXX'
count = 5
contact_list = []
property_list = ["city"]
get_all_contacts_url = "http://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=XXX&property=city"
headers = {}
# Paginate your request using offset
has_more = True
while has_more:
parameters = urllib.parse.urlencode(parameter_dict)
get_url = get_all_contacts_url + parameters
r = requests.get(url= get_url, headers = headers)
response_dict = json.loads(r.text)
has_more = response_dict['has-more']
contact_list.extend(response_dict['contacts'])
parameter_dict['vidOffset']= response_dict['vid-offset']
if len(contact_list) >= max_results: # Exit pagination, based on whatever value you've set your max results variable to.
print('maximum number of results exceeded')
break
print('loop finished')
list_length = len(contact_list)
print("You've succesfully parsed through {} contact records and added them to a list".format(list_length))