I’m building out a call to add existing contacts to a list, but I’m having some issue just getting the list without getting a 400 error.
This is what I currently have:
def hubspot_read_list(emails, app_download):
url = “https://api.hubapi.com/contacts/v1/lists/30/add?hapikey=OUR_KEY”
jsond = {
“emails”: [
“test123@gmail.com”
],
“app_download”: [
True
]
}
data = json.dumps(jsond)
req = urllib2.Request(url, data, {‘Content-Type’:‘application/json’, ‘Accept’:‘application/json’})
content = urllib2.urlopen(req).read()
Here’s the POST for all contacts, which is connecting to the Hubspot portal correctly
def hubspot_add(email, fname, lname, goal, wink_status):
url = "https://api.hubapi.com/contacts/v1/contact?hapikey=OUR_KEY"
jsond = {
"properties": [
{
"property": "email",
"value": email
},
{
"property": "firstname",
"value": fname
},
{
"property": "lastname",
"value": lname
},
{
"property": "goal",
"value": goal
},
{
"property": "wink_status",
"value": wink_status
},
{
"property": "app_download",
"value": True
}
]
}
data = json.dumps(jsond)
req = urllib2.Request(url, data, {'Content-Type': 'application/json'})
content = urllib2.urlopen(req).read()
