Unable to add contacts to lists

contacts

#1

Hi guys,

We used to use Hubspot’s Contact APIs to push emails to specific lists. For some reason it stopped working as of Nov 4th and we still haven’t been able to figure out why.

The endpoint is a POST to http://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/:email http://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/:email/` with the body containing the email property. Did this API endpoint change?

We also tried to manually connect and it gives a 403/Not
authorized responses error code.

Arun


#2

Hi @Arun-Flixel

There haven’t been any recent changes to that endpoint that should cause a 403 error. Do you have any more details about the request or response? Normally you’ll see more details in the body of the response message.


#3

Hi David, So this is the code we’re using to add the emails:

class Hubspot(object):

def __init__(self, api_key=None):
    self.api_key = settings.HUBSPOT_API_KEY if api_key is None else api_key
    

def add_email(self, email=None, list_id=None):
    h = httplib2.Http()
    body = { 'properties' : [ { 'property': 'email', 'value':email } ] }
    # Add the email to Hubspot contacts
    resp, content = h.request(self._hubspot_api_string("contacts/v1/contact/createOrUpdate/email/%s/" % email), method="POST", body=json.dumps(body))            

    if resp['status'] == "200" and list_id is not None:
        user_id = json.loads(content)['vid']
        body = { 'vids' : [ user_id ] }
        # Add the contact to the list
        resp, content = h.request(self._hubspot_api_string("contacts/v1/lists/%s/add" % list_id), method="POST", body=json.dumps(body))

def _hubspot_api_string(self, path=None):
    return "http://api.hubapi.com/%s?hapikey=%s" % (path, self.api_key)