# 'SimplePublicObjectWithAssociations' object has no attribute 'values'

**URL:** <https://community.hubspot.com/t/simplepublicobjectwithassociations-object-has-no-attribute-values/81782>\
**Category:** APIs & Integrations\
**Tags:** free\
**Created:** [May 23, 2023, 11:08am UTC](https://community.hubspot.com/t/simplepublicobjectwithassociations-object-has-no-attribute-values/81782 "2023-05-23T11:08:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JRourke](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@JRourke](https://community.hubspot.com/u/JRourke)\
**Post date:** [May 23, 2023, 11:08am UTC](https://community.hubspot.com/t/simplepublicobjectwithassociations-object-has-no-attribute-values/81782/1 "2023-05-23T11:08:27Z")

</div>

I’m trying to create an analytics pipeline in Python / Jupyter. I have been able to access contacts and deals data using api\_client.crm.contacts.get\_all() which provides me wit a JSON Class ‘List’. If I copy and paste this output and use json\_normalize, I am able to convert it into a dataframe. However if I attempt to access the data directly I get the following error: ‘SimplePublicObjectWithAssociations’ object has no attribute ‘values’ or cannot unpack non-iterable SimplePublicObjectWithAssociations object. Every attempt I’ve made to convert SimplePublicObjectWithAssociations has failed. Further I have been able to access single records by their ID, suggesting that something on the Hubspot side is not allowing me to loop over the contacts data to pull it all into Jupyter. Has anyone else encountered this issue?

code:  
all\_contacts = api\_client.crm.contacts.get\_all()

data = all\_contacts

df = pd.json\_normalize(data, max\_level=2)

‘SimplePublicObjectWithAssociations’ object has no attribute ‘values’  
data = all\_contacts  
for i,x in data:  
data[i]= x.to\_dict()  
df = json.loads(data, max\_level=2)

cannot unpack non-iterable SimplePublicObjectWithAssociations object

---

<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:** [May 24, 2023, 11:19pm UTC](https://community.hubspot.com/t/simplepublicobjectwithassociations-object-has-no-attribute-values/81782/2 "2023-05-24T23:19:08Z")

</div>

Hey, @JRourke 👋 Thanks for your question.

While I’m no expert in Python, I know a few — 👋 @JBeatty @ChrisoKlepke @Klapprodt 👋  
I have a few questions that can help the community be better informed about your project:

- Did you try converting the ‘SimplePublicObjectWithAssociations’ objects to dictionaries using the `to_dict()` method before passing them to `pd.json_normalize`?
- Can you clarify what you’re trying to achieve with your second loop?

Thank you! — Jaycee

---

<div class="post-metadata">

**Author:** ![Klapprodt](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/klapprodt/32/15151_2.png) [@Klapprodt](https://community.hubspot.com/u/Klapprodt)\
**Post date:** [May 25, 2023, 7:10am UTC](https://community.hubspot.com/t/simplepublicobjectwithassociations-object-has-no-attribute-values/81782/3 "2023-05-25T07:10:50Z")

</div>

Hi @JRourke ,

I think there is a step missing. Try this:

```lia-code-sample
all_contacts = api_client.crm.contacts.get_all()

contacts_list = []

for contact in all_contacts:
contacts_list.append(contact.to_dict())

contacts_df = pd.json_normalize(contacts_list, max_level=2)

contacts_df.head(5)

```

----

If you want to get a single contact by ID, try this:

`contact = api_client.crm.contacts.basic_api.get_by_id('112358')`

Cheers,  
Marcus

---

<div class="post-metadata">

**Author:** ![JRourke](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@JRourke](https://community.hubspot.com/u/JRourke)\
**Post date:** [May 25, 2023, 10:13am UTC](https://community.hubspot.com/t/simplepublicobjectwithassociations-object-has-no-attribute-values/81782/4 "2023-05-25T10:13:50Z")

</div>

Thank you Marcus!  
This method converts it into a **pandas.core.frame.Pandas,** which can then be turned into a data frame using the following “pd.DataFrame(contacts\_df)”.  
Appreciate your input!

---

<div class="post-metadata">

**Author:** ![Klapprodt](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/klapprodt/32/15151_2.png) [@Klapprodt](https://community.hubspot.com/u/Klapprodt)\
**Post date:** [May 25, 2023, 11:00am UTC](https://community.hubspot.com/t/simplepublicobjectwithassociations-object-has-no-attribute-values/81782/5 "2023-05-25T11:00:47Z")

</div>

Happy to help 👍
