Python API issues

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:

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

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

Thanks! — Jaycee

Same problem, unfortunately. Let me know if you’ve found a fix.