# Python API issues

**URL:** <https://community.hubspot.com/t/python-api-issues/110368>\
**Category:** APIs & Integrations\
**Tags:** python\
**Created:** [June 28, 2024, 5:23pm UTC](https://community.hubspot.com/t/python-api-issues/110368 "2024-06-28T17:23:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ADiaz89](https://avatars.discourse-cdn.com/v4/letter/a/e0b2c6/32.png) [@ADiaz89](https://community.hubspot.com/u/ADiaz89)\
**Post date:** [June 28, 2024, 5:23pm UTC](https://community.hubspot.com/t/python-api-issues/110368/1 "2024-06-28T17:23:46Z")

</div>

Hello, Im trying to make a push of some contacts thorugh the API

but Im getting this error:

‘Discovery’ object has no attribute ‘memberships\_api’  
This is my code:

```lia-code-sample
import psycopg2
import hubspot
from pprint import pprint
from hubspot.crm.lists import ApiException

# PostgreSQL connection details
pg_host = 'pg_host'
pg_port = 'pg_port'
pg_database = 'pg_database'
pg_user = 'pg_user'
pg_password = 'pg_password'

# HubSpot API details
hubspot_list_id = '23'
list_name = 'New List'
client = hubspot.Client.create(access_token="pat-XXXXX")

def get_postgres_data():
conn = None
data = []
try:
conn = psycopg2.connect(
host=pg_host,
port=pg_port,
database=pg_database,
user=pg_user,
password=pg_password
)
cur = conn.cursor()
cur.execute("select * from new_list")
rows = cur.fetchall()
for row in rows:
data.append({'name': row[0], 'email': row[1]})
print("Connection done")
cur.close()
except Exception as error:
print(f"Error fetching data from PostgreSQL: {error}")
#finally:
#if conn is not None:
#conn.close()
return data

get_postgres_data()

def push_to_hubspot():
data=get_postgres_data()
try:
for d in data:

api_response = client.crm.lists.memberships_api.add(list_id=hubspot_list_id, undefined=[d['name'],d['email']])
pprint(api_response)
except ApiException as e:
print("Exception when calling memberships_api->add: %s\n" % e)

push_to_hubspot()

```

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [June 28, 2024, 9:59pm UTC](https://community.hubspot.com/t/python-api-issues/110368/2 "2024-06-28T21:59:47Z")

</div>

Hey, @ADiaz89 👋 Do you get the same, or a similar, error when you test using the on-page example or when using Postman?

Thanks! — Jaycee

---

<div class="post-metadata">

**Author:** ![ATommy](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@ATommy](https://community.hubspot.com/u/ATommy)\
**Post date:** [August 1, 2024, 9:56pm UTC](https://community.hubspot.com/t/python-api-issues/110368/3 "2024-08-01T21:56:00Z")

</div>

Same problem, unfortunately[.](https://mybakersfieldrealtor.com/moving-to-bakersfield/) Let me know if you’ve found a fix.
