Hello friends,
I’m working on a Python script that will read object properties, and needs to determine whether or not a property is one of the default properties created by HubSpot. I’m running into issues in Python determining whether the “hubspotDefined” value is True. JSON returns as “true”, whereas Python looks for “True”. I’ve read some articles on other sites but was hoping that someone has already done this particular excersise on the values returned by HubSpot’s properties API.
Example of one of the properties returned in read all properties API:
{
"updatedAt": "2019-09-23T17:45:44.354Z",
"createdAt": "2019-08-06T02:41:10.544Z",
"name": "hs_searchable_calculated_international_mobile_number",
"label": "Calculated Mobile Number with country code",
"type": "phone_number",
"fieldType": "phonenumber",
"description": "Mobile number with country code",
"groupName": "contactinformation",
"options": [],
"displayOrder": -1,
"calculated": true,
"externalOptions": false,
"hasUniqueValue": false,
"hidden": true,
"hubspotDefined": true,
"modificationMetadata": {
"archivable": true,
"readOnlyDefinition": true,
"readOnlyValue": true
},
"formField": false
}
A short section of the Python code I’m using:
from_contact_properties_response = requests.request("GET", from_contact_properties_url, headers=from_contact_properties_headers, data=from_contact_properties_payload)
from_contact_properties_data = from_contact_properties_response.json()
from_contact_properties = from_contact_properties_data['results']
to_contact_properties_inputs = []
for i in from_contact_properties:
if i["hubspotDefined"] == True:
print(i)
else:
to_contact_properties_inputs.append(i)
The overall response to json approach is something I’ve used many times before, and works fine for reading if the “name” key contains certain text, if the “fieldType” is equal to a certain value, etc. First time trying to use logic based on the boolean fields though, and this is giving issues. I’m hoping that I don’t have to completely redo how I’ve been making calls and retrieving and reading requests, but if necessary I will make those adjustments.
Thank you!