I’m using the below code to get companies associated with a deal. It works for some but not others. What is causing them to not return to a company? I’ve checked in HubSpot and there is a company associated with the deals. What needs to be fixed and where is the fix (my code, HubSpot, etc.)? Thank you!
max_results = 10000
hapikey = 'my key'
limit = 100
deal_client_list = []
parameter_dict = {'hapikey': hapikey, 'limit': limit}
headers = {}
for i in range(0,len(data.index)):
# Paginate your request using offset
has_more = True
while has_more:
parameters = urllib.parse.urlencode(parameter_dict)
get_url = "https://api.hubapi.com/crm-associations/v1/associations/"+ data['DealId'].iloc[i].astype(str) +"/HUBSPOT_DEFINED/5?" + parameters
r = requests.get(url = get_url, headers = headers)
response_dict = json.loads(r.text)
has_more = response_dict['hasMore']
parameter_dict['offset']= response_dict['offset']
extra = {"dealid":data['DealId'].iloc[i].astype(str)}
response_dict.update(extra)
deal_client_list.append(response_dict)
if len(deal_client_list) >= max_results: # Exit pagination, based on whatever value you've set your max results variable to.
print('maximum number of results exceeded')
break