This is the request
from hubspot import HubSpot
import hubspot
from pprint import pprint
from hubspot.crm.schemas import ObjectSchemaEgg, ApiException
api_client = hubspot.Client.create(access_token=TOKEN)
labels = {
"singular": "Test CO",
"plural": "Test CO"
}
object_schema_egg = ObjectSchemaEgg(
labels=labels,
required_properties=["application_id", "status", "affiliate"],
searchable_properties=["status"],
primary_display_property="status",
secondary_display_properties=[],
properties=[{
"name":"application_id",
"label":"Application ID",
"isPrimaryDisplayLabel": False},
{
"name":"status",
"label":"Status",
"isPrimaryDisplayLabel": True},
{
"name":"affiliate",
"label":"Affiliate",
"isPrimaryDisplayLabel": False}],
associated_objects=["CONTACT"],
name="testcustomschema")
try:
api_response = api_client.crm.schemas.core_api.create(object_schema_egg=object_schema_egg)
pprint(api_response)
except ApiException as e:
print("Exception when calling core_api->create: %s\n" % e)
and the response is
Exception when calling core_api->create: (401)
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Date': 'Fri, 07 Oct 2022 16:36:21 GMT', 'Content-Type': 'application/json;charset=utf-8', 'Content-Length': '316', 'Connection': 'keep-alive', 'CF-Ray': '75680e1f483b9903-ARN', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'Vary': 'origin, Accept-Encoding', 'CF-Cache-Status': 'DYNAMIC', 'Access-Control-Allow-Credentials': 'false', 'X-HubSpot-Auth-Failure': '401 Unauthorized', 'X-HubSpot-Correlation-Id': '4775757c-77a8-4b7c-934e-00e2310e68a4', 'Report-To': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=wXo1FpFtLOsOueMqu3zT2yVhdcW5StSUmVyUCRW16oRpyO4wCTSMVELyfdCQ8xy%2BjqIISf7kBKz4CcKsFIjpqvb7eIYZRk4nWYkrgxVT%2Bv7aUZpJvm6qWz4IExp3JMAT"}],"group":"cf-nel","max_age":604800}', 'NEL': '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}', 'Server': 'cloudflare', 'alt-svc': 'h3=":443"; ma=86400, h3-29=":443"; ma=86400'})
HTTP response body: {"status":"error","message":"Authentication credentials not found. This API supports both API Key and OAuth 2.0 authentication and you can find more details at https://developers.hubspot.com/docs/methods/auth/oauth-overview","correlationId":"4775757c-77a8-4b7c-934e-00e2310e68a4","category":"INVALID_AUTHENTICATION"}
The same api client and token works for e.g. fetching custom objects if they’re created using the beta UI