APIs & Integrations

karien
Participant

Get objectId by property value....

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

0 Upvotes
3 Replies 3
LeeBartelme
HubSpot Employee
HubSpot Employee

Get objectId by property value....

I believe the search API is what you want.

https://developers.hubspot.com/docs/api/crm/search

karien
Participant

Get objectId by property value....

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

0 Upvotes
karien
Participant

Get objectId by property value....

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)


 

0 Upvotes