<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how do i convert 'SimplePublicObjectWithAssociations' in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/771091#M62393</link>
    <description>&lt;P&gt;You're welcome. Happy to help &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Mar 2023 13:48:32 GMT</pubDate>
    <dc:creator>Klapprodt</dc:creator>
    <dc:date>2023-03-20T13:48:32Z</dc:date>
    <item>
      <title>how do i convert 'SimplePublicObjectWithAssociations'</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/687791#M56519</link>
      <description>&lt;P&gt;the JSON object must be str, bytes or bytearray, not 'SimplePublicObjectWithAssociations'&lt;/P&gt;&lt;P&gt;i tried with Json.. output looks Json or like python dict but obviously isn't?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 18:35:44 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/687791#M56519</guid>
      <dc:creator>karien</dc:creator>
      <dc:date>2022-08-31T18:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: how do i convert 'SimplePublicObjectWithAssociations'</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/688433#M56580</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/381889"&gt;@karien&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; Thanks for reaching out. Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/401263"&gt;@LeeBartelme&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/144301"&gt;@taran42&lt;/a&gt;, do y'all have any insight here for&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/381889"&gt;@karien&lt;/a&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you! Jaycee&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 20:34:49 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/688433#M56580</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2022-09-01T20:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: how do i convert 'SimplePublicObjectWithAssociations'</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/688435#M56581</link>
      <description>&lt;P&gt;Seeing the code you are having trouble with and an idea of the goal behind what you are doing would help diagnose the issue.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 20:39:00 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/688435#M56581</guid>
      <dc:creator>LeeBartelme</dc:creator>
      <dc:date>2022-09-01T20:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: how do i convert 'SimplePublicObjectWithAssociations'</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/688443#M56583</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;GOAL == get first and last name of objectid (contacts)&lt;BR /&gt;&lt;BR /&gt;thx Lee, i condensed whats important in the code and pertaining to the issue. &lt;BR /&gt;I need to get the simplePublicObject* type returned converted to Dict. &lt;BR /&gt;to be able to unpack it&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;import &lt;/SPAN&gt;hubspot&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;os&lt;BR /&gt;import json&lt;BR /&gt;&lt;BR /&gt;client = hubspot.Client.create(&lt;SPAN&gt;api_key&lt;/SPAN&gt;=&lt;SPAN&gt;"api_key"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#def main(event):&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;get_first_last_name_by_contact_id&lt;/SPAN&gt;():&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;    &lt;SPAN&gt;#object_id_contact = event.get('inputFields').get('')&lt;BR /&gt;    object_id_contact = "12468101"&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;OAUTH &lt;/SPAN&gt;= os.getenv(&lt;SPAN&gt;'OAUTH'&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;try&lt;/SPAN&gt;:&lt;BR /&gt;&lt;BR /&gt;        api_response = client.crm.objects.basic_api.get_by_id(&lt;SPAN&gt;object_type&lt;/SPAN&gt;=&lt;SPAN&gt;"0-1"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;                                                             object_id&lt;/SPAN&gt;=&lt;SPAN&gt;f'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;object_id_contact&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;                                                             &lt;SPAN&gt;properties&lt;/SPAN&gt;=[&lt;SPAN&gt;"firstname"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"lastname"&lt;/SPAN&gt;]&lt;SPAN&gt;, &lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;                                                             archived&lt;/SPAN&gt;=&lt;SPAN&gt;False&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;     &lt;SPAN&gt;except &lt;/SPAN&gt;ApiException &lt;SPAN&gt;as &lt;/SPAN&gt;e:&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;"Exception when calling basic_api-&amp;gt;get_by_id: %s&lt;/SPAN&gt;&lt;SPAN&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;% e)&lt;BR /&gt;     &lt;BR /&gt;        &lt;BR /&gt;&lt;SPAN&gt;  return &lt;/SPAN&gt;api_response -&amp;gt; 200&lt;BR /&gt;-&amp;gt; {"archived": False,&lt;BR /&gt;"archived_at": 1,&lt;BR /&gt;"associations": 1,&lt;BR /&gt;"created_at": datetime.datetime(2022, 6, 16, 11, 55, 49, 19000, tzinfo=tzutc()),&lt;BR /&gt;"id": "12468101",&lt;BR /&gt;"properties": {"createdate": "2022-06-16T11:55:49.019Z",&lt;BR /&gt;"firstname": "Karien",&lt;BR /&gt;"hs_object_id": "12468101",&lt;BR /&gt;"lastmodifieddate": "2022-09-01T09:43:44.443Z",&lt;BR /&gt;"lastname": "Skinner"},&lt;BR /&gt;"properties_with_history": 1,&lt;BR /&gt;"updated_at": datetime.datetime(2022, 9, 1, 9, 43, 44, 443000, tzinfo=tzutc())}&lt;BR /&gt;        &lt;BR /&gt;         #below is what i tried amongst other things to try make json.load work.&lt;BR /&gt;         api_string = (&lt;SPAN&gt;str&lt;/SPAN&gt;(api_response))&lt;BR /&gt;         api_string = api_string.replace(&lt;SPAN&gt;"'"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'"'&lt;/SPAN&gt;) #double quotes needed for json&lt;BR /&gt;         #try to convert to dict error - i need to unpack my output to get first and last names&lt;BR /&gt;&lt;BR /&gt;         &lt;SPAN&gt;json_data = json.loads(api_string)&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;         print(json_data) -&amp;gt; raise JSONDecodeError("Expecting value", s, err.value) from None&lt;BR /&gt;   json.decoder.JSONDecodeError: Expecting value&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;details = get_first_last_name_by_contact_id()&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(details)&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 21:43:40 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/688443#M56583</guid>
      <dc:creator>karien</dc:creator>
      <dc:date>2022-09-01T21:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: how do i convert 'SimplePublicObjectWithAssociations'</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/689064#M56613</link>
      <description>&lt;P&gt;ok i found my problem, i dont need to use json to convert this object into dict. so i can unpack it....&lt;/P&gt;&lt;P&gt;i simply need to use the response to get what i need... how easy is that, thats if you know....no conversions needed... no unpacking of nested dictionaries.... lists etc.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;api_response = client.crm.objects.basic_api.get_by_id(&lt;SPAN&gt;object_type&lt;/SPAN&gt;=&lt;SPAN&gt;"0-1"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;object_id&lt;/SPAN&gt;=&lt;SPAN&gt;f'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;object_id_contact&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;                                                      &lt;SPAN&gt;properties&lt;/SPAN&gt;=[&lt;SPAN&gt;"firstname"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"lastname"&lt;/SPAN&gt;]&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;archived&lt;/SPAN&gt;=&lt;SPAN&gt;False&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;firstname = api_response.properties[&lt;SPAN&gt;"firstname"&lt;/SPAN&gt;]&lt;BR /&gt;&lt;BR /&gt;--&amp;gt;Karien&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 06:43:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/689064#M56613</guid>
      <dc:creator>karien</dc:creator>
      <dc:date>2022-09-03T06:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: how do i convert 'SimplePublicObjectWithAssociations'</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/689080#M56616</link>
      <description>&lt;P&gt;and also a note, its for this specific case where i have access to the properties, in other case you do need to convert to dict --&amp;gt; (json)&amp;nbsp;&lt;BR /&gt;if this can help someone else i used below to convert to dict for another use case&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;api_response = client.crm.objects.associations_api.get_all(&lt;SPAN&gt;object_type&lt;/SPAN&gt;=&lt;SPAN&gt;"2-7431691"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;object_id&lt;/SPAN&gt;=&lt;SPAN&gt;f'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;object_id_sg&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;to_object_type&lt;/SPAN&gt;=&lt;SPAN&gt;"0-1"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;BR /&gt;api_string = (&lt;SPAN&gt;str&lt;/SPAN&gt;(api_response))&lt;BR /&gt;api_string = api_string.replace(&lt;SPAN&gt;"'"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'"'&lt;/SPAN&gt;)#for json needs double quotes&lt;BR /&gt;api_string = api_string.replace(&lt;SPAN&gt;'None'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"1"&lt;/SPAN&gt;)#to avoid none error&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;type&lt;/SPAN&gt;(api_string))&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(api_string)&lt;BR /&gt;json_data = json.loads(api_string)&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;type&lt;/SPAN&gt;(json_data))&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(json_data)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2022 10:09:21 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/689080#M56616</guid>
      <dc:creator>karien</dc:creator>
      <dc:date>2022-09-03T10:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: how do i convert 'SimplePublicObjectWithAssociations'</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/689083#M56618</link>
      <description>&lt;P&gt;in another use case i did need to convert to dict. and had some errors, to correct those i did the following&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;api_response = client.crm.objects.associations_api.get_all(&lt;SPAN&gt;object_type&lt;/SPAN&gt;=&lt;SPAN&gt;"2-7431691"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;object_id&lt;/SPAN&gt;=&lt;SPAN&gt;f'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;object_id_sg&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;to_object_type&lt;/SPAN&gt;=&lt;SPAN&gt;"0-1"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;api_string = (&lt;SPAN&gt;str&lt;/SPAN&gt;(api_response))&lt;BR /&gt;api_string = api_string.replace(&lt;SPAN&gt;"'"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'"'&lt;/SPAN&gt;)&lt;BR /&gt;api_string = api_string.replace(&lt;SPAN&gt;'None'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"1"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;json_data = json.loads(api_string)&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Sep 2022 10:25:24 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/689083#M56618</guid>
      <dc:creator>karien</dc:creator>
      <dc:date>2022-09-03T10:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: how do i convert 'SimplePublicObjectWithAssociations'</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/753151#M61224</link>
      <description>&lt;P&gt;I had the same problem.&lt;BR /&gt;&lt;BR /&gt;The Hubspot objects have a method called "&lt;EM&gt;.to_dict()"&lt;/EM&gt;, that you can use.&amp;nbsp;&lt;BR /&gt;Just change them to a dict and then convert them to json.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Klapprodt_0-1675843979184.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/84896i772B6E6E6CFE4037/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Klapprodt_0-1675843979184.png" alt="Klapprodt_0-1675843979184.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 08:18:21 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/753151#M61224</guid>
      <dc:creator>Klapprodt</dc:creator>
      <dc:date>2023-02-08T08:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: how do i convert 'SimplePublicObjectWithAssociations'</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/770691#M62370</link>
      <description>&lt;P&gt;ah thx for sharing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2023 22:25:31 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/770691#M62370</guid>
      <dc:creator>karien</dc:creator>
      <dc:date>2023-03-18T22:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: how do i convert 'SimplePublicObjectWithAssociations'</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/771091#M62393</link>
      <description>&lt;P&gt;You're welcome. Happy to help &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 13:48:32 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/how-do-i-convert-SimplePublicObjectWithAssociations/m-p/771091#M62393</guid>
      <dc:creator>Klapprodt</dc:creator>
      <dc:date>2023-03-20T13:48:32Z</dc:date>
    </item>
  </channel>
</rss>

