# Discovery object has no attribute basic\_api

**URL:** <https://community.hubspot.com/t/discovery-object-has-no-attribute-basic-api/112965>\
**Category:** APIs & Integrations\
**Tags:** crm, contacts\
**Created:** [July 26, 2024, 10:28am UTC](https://community.hubspot.com/t/discovery-object-has-no-attribute-basic-api/112965 "2024-07-26T10:28:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ARasool07](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@ARasool07](https://community.hubspot.com/u/ARasool07)\
**Post date:** [July 26, 2024, 10:28am UTC](https://community.hubspot.com/t/discovery-object-has-no-attribute-basic-api/112965/1 "2024-07-26T10:28:52Z")

</div>

Hi Everyone,  
with the v4 api, I’m trying to get the associations, I just upgraded hubspot api from 7.0.0 to 9.0.0, but its the same code which runs well on the documentation website but doesn’t work when I run it on my laptop.  
I’ve the following environment  
IDE: JupyterNotebook  
Python Version: 3.11.3  
hubspot-api-client: 9.0.0

script is as follow

```auto
try:
 api_response = client.crm.associations.v4.basic_api.get_page(object_type="contact", object_id="4115", to_object_type="2-118112", limit=10)
 pprint(api_response)
except ApiException as e:
 print("Exception when calling basic_api->get_page: %s\n" % e)

```

the error message:

`AttributeError: 'Discovery' object has no attribute 'basic_api'`

when I check dir with

`dir(client.crm.associations)`

i get the following

```lia-code-sample
['class',
'delattr',
'dict',
'dir',
'doc',
'eq',
'format',
'ge',
'getattribute',
'getstate',
'gt',
'hash',
'init',
'init_subclass',
'le',
'lt',
'module',
'ne',
'new',
'reduce',
'reduce_ex',
'repr',
'setattr',
'sizeof',
'str',
'subclasshook',
'weakref',
'_configure_api_client',
'_default_api_factory',
'batch_api',
'config',
'types_api',
'v4']

```

---

<div class="post-metadata">

**Author:** ![Berangere](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/berangere/32/220784_2.png) [@Berangere](https://community.hubspot.com/u/Berangere)\
**Post date:** [July 29, 2024, 7:09am UTC](https://community.hubspot.com/t/discovery-object-has-no-attribute-basic-api/112965/2 "2024-07-29T07:09:06Z")

</div>

Hi @ARasool07 and welcome to the Community!  
We are so glad to have you here!  
Thank you for asking the Community!  
I have found a similar post “[Read Associations v4 Python AttributeError: ‘BasicApi’ object has no attribute 'get\_crm\_v4\_objects\_o](https://community.hubspot.com/t5/APIs-Integrations/Read-Associations-v4-Python-AttributeError-BasicApi-object-has/td-p/861054)” for you where the replies from [@zach\_threadint](https://community.hubspot.com/t5/user/viewprofilepage/user-id/324811) might help you!  
Also, @PIntegration have you been able to solve this, please?  
If anybody else has anything to add and/or share, please feel free to join in the conversation 🙂  
Thanks a lot and have a lovely day!  
Best,  
Bérangère

---

<div class="post-metadata">

**Author:** ![zach\_threadint](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zach_threadint/32/46318_2.png) [@zach\_threadint](https://community.hubspot.com/u/zach_threadint)\
**Post date:** [July 30, 2024, 12:06am UTC](https://community.hubspot.com/t/discovery-object-has-no-attribute-basic-api/112965/3 "2024-07-30T00:06:02Z")

</div>

Hi @ARasool07 👋

Looks like it’ll be a version compatibility issue. I’ve managed to get the relevant [API docs example Python code](https://developers.hubspot.com/beta-docs/reference/api/crm/associations/association-details#get-%2Fcrm%2Fv4%2Fobjects%2F%7Bobjecttype%7D%2F%7Bobjectid%7D%2Fassociations%2F%7Btoobjecttype%7D) to work (which is consistent with the example you’ve supplied) in a HubSpot Workflow custom code action (Python 3.9, HS Client v8). I generally avoid using the client libraries (mainly because of these compatibility / documentation issues), in favour of the Python “requests” library. In this case, you could do something like:

```lia-code-sample
import requests
import os

# replace placeholders as required
endpoint = "https://api.hubapi.com/crm/v4/objects/{FROM_OBJECT_TYPE}/{FROM_RECORD_ID}/associations/{TO_OBJECT_TYPE}"
params = {
 "limit": 10
}
# replace ACCESS_TOKEN with your private access token
headers = {
 "Authorization": "Bearer {}".format(ACCESS_TOKEN)
}
response = requests.get(endpoint, params=params, headers=headers)
if response.status_code == 200:
 print(response.json())
else:
 print(response.status_code)
 print(response.text)

```

I hope this proves helpful. Please let me know if you have any follow-up questions.

---

<div class="post-metadata">

**Author:** ![ARasool07](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@ARasool07](https://community.hubspot.com/u/ARasool07)\
**Post date:** [July 30, 2024, 7:41am UTC](https://community.hubspot.com/t/discovery-object-has-no-attribute-basic-api/112965/4 "2024-07-30T07:41:48Z")

</div>

Hi [@zach\_threadint](https://community.hubspot.com/t5/user/viewprofilepage/user-id/324811) thanks for the tip, yes it worked with request liberary, I’ll surely keep your tip in mind for future to use requests and avoid clients as much as possible. Thanks a lot.
