We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Aug 31, 2022 3:16 AM
is it possible to retrieve the objectId by property value?
ContactId by email ?
CustomObjectId by property value?
Any help will be greatly appreciated.
id prefer not to have to read all objects and then search for the ID by property value. thousands of objects.
If someone can point me to in the right directions, id greatly appreciate it. thx
Aug 31, 2022 8:29 AM
I believe the search API is what you want.
https://developers.hubspot.com/docs/api/crm/search
Aug 31, 2022 2:41 PM - edited Aug 31, 2022 2:41 PM
thank you Lee
try:
api_response = client.crm.objects.basic_api.get_by_id(object_type="0-1", object_id=f'{object_id_contact}', properties=["firstname","lastname"], archived=False)
pprint(api_response)
json_data = json.loads(api_response)
print(json_data)
exception = the JSON object must be str, bytes or bytearray, not 'SimplePublicObjectWithAssociations'
how do i convert this "simplePublicObject*" to dict or anything i can unpack? do you know? thx
Aug 31, 2022 2:45 PM - edited Aug 31, 2022 3:24 PM
ok i tried converting to string, its working but new line (/n) included, just more work. if you maybe know of better way, preferrably dict. im not familiar with this object type.
and thx for your response.
i tried
api_response = client.crm.objects.basic_api.get_by_id(object_type="0-1", object_id=f'{object_id_contact}', properties=["firstname","lastname"], archived=False)
api_string = (str(api_response))
api_string = api_string.replace("'", '"')
res = json.loads(api_string)
print(str(res))
print("The converted dictionary : " + str(res))
--> raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 14 (char 13)