# 400 Bad Request Python

**URL:** <https://community.hubspot.com/t/400-bad-request-python/12509>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [December 17, 2018, 5:10pm UTC](https://community.hubspot.com/t/400-bad-request-python/12509 "2018-12-17T17:10:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [December 17, 2018, 5:10pm UTC](https://community.hubspot.com/t/400-bad-request-python/12509/1 "2018-12-17T17:10:28Z")

</div>

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](https://api.hubapi.com/contacts/v1/lists/30/add?hapikey=OUR_KEY)”  
jsond = {  
“emails”: [  
“[test123@gmail.com](mailto: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):

```auto
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()

```

---

<div class="post-metadata">

**Author:** ![cbarley](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cbarley/32/82559_2.png) [@cbarley](https://community.hubspot.com/u/cbarley)\
**Post date:** [December 18, 2018, 5:39pm UTC](https://community.hubspot.com/t/400-bad-request-python/12509/2 "2018-12-18T17:39:16Z")

</div>

Hi [@keilahoover](https://community.hubspot.com/u/keilahoover), which endpoint are you using? If you’re simply looking to add contacts to a list, you should be using this one: [https://developers.hubspot.com/docs/methods/lists/add\_contact\_to\_list](https://developers.hubspot.com/docs/methods/lists/add_contact_to_list). This endpoint _does not_ accept properties like you’re formatting above. It should only have the `emails` or `vids` array in the body, and not the `app_download` property.

Your body looks like you’re trying to [create a contact](https://developers.hubspot.com/docs/methods/contacts/create_contact), then add them to a list where contact’s have the `app_download` property equal to true. If this is the case, I’d just create an active list in HubSpot with te condition that `app_download` is equal to true, then create contacts using the contacts API with the `app_download` property included in the JSON body

Please clarify your goals if I’m off base. Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [December 18, 2018, 7:27pm UTC](https://community.hubspot.com/t/400-bad-request-python/12509/3 "2018-12-18T19:27:03Z")

</div>

That latter suggestion worked perfectly. Thank you!

---

<div class="post-metadata">

**Author:** ![cbarley](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cbarley/32/82559_2.png) [@cbarley](https://community.hubspot.com/u/cbarley)\
**Post date:** [December 18, 2018, 7:29pm UTC](https://community.hubspot.com/t/400-bad-request-python/12509/4 "2018-12-18T19:29:25Z")

</div>

Great to hear! Glad you got it set up properly  
 ![slight_smile.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/3/33fb2a14544119c2351fe774141779702299e6a6.png)
