Importing Custom Objects

I’m trying to test imports with custom objects via the API and running into an issue; every request I make to create the import results in

{

“status”: “error”,

“message”: “Unable to process JSON”,

“correlationId”: “96da51cf-3b56-4baa-84e7-9d5100b05b3f”

}

I’ve created a “User” custom object in my Hubspot instance for testing with three fields: email, first_name, and last_name.

Based on the import API docs, I’m trying the following as the JSON payload for my import request:

{
 "name": "Polytomic (7f80d29a-5c8f-4dd8-9829-d010f5833c72 / 1)",
 "files": [
 {
 "fileName": "import.csv",
 "fileFormat": "CSV",
 "fileImportPage": {
 "hasHeader": true,
 "columnMappings": [
 {
 "ignored": false,
 "columnName": "email",
 "idColumnType": null,
 "propertyName": "email",
 "foreignKeyType": null,
 "columnObjectType": "2-1087393",
 "associationIdentifierColumn": false
 },
 {
 "ignored": false,
 "columnName": "first_name",
 "idColumnType": null,
 "propertyName": "first_name",
 "foreignKeyType": null,
 "columnObjectType": "2-1087393",
 "associationIdentifierColumn": false
 },
 {
 "ignored": false,
 "columnName": "last_name",
 "idColumnType": null,
 "propertyName": "last_name",
 "foreignKeyType": null,
 "columnObjectType": "2-1087393",
 "associationIdentifierColumn": false
 }
 ]
 }
 }
 ]
}

I receive the same error in my code as well as via Postman, so I’m assuming there’s an issue with one of the values; columnObjectType seems the most likely (to me, at least), so I’ve tried the following custom object properties for that value:

  • id
  • objectTypeId
  • name
  • fullyQualifiedName

Is there something else I should be using? Some other way to refer to properties? Any help would be greatly appreciated. I’m including my custom object definition below for completeness.

Thanks!

 {
 "labels": {
 "singular": "User",
 "plural": "Users"
 },
 "requiredProperties": [
 "email"
 ],
 "searchableProperties": [
 "email"
 ],
 "primaryDisplayProperty": "email",
 "secondaryDisplayProperties": [],
 "restorable": true,
 "metaType": "PORTAL_SPECIFIC",
 "id": "1087393",
 "fullyQualifiedName": "p8439367_users",
 "createdAt": "2020-09-29T16:30:29.085Z",
 "updatedAt": "2020-09-29T16:30:29.085Z",
 "objectTypeId": "2-1087393",
 "properties": [
 {
 "updatedAt": "2020-09-29T16:30:29.256Z",
 "createdAt": "2020-09-29T16:30:29.256Z",
 "name": "email",
 "label": "Email",
 "type": "string",
 "fieldType": "text",
 "groupName": "users_information",
 "displayOrder": -1,
 "calculated": false,
 "externalOptions": false,
 "archived": false,
 "hasUniqueValue": false,
 "hidden": false,
 "modificationMetadata": {
 "archivable": true,
 "readOnlyDefinition": false,
 "readOnlyValue": false
 },
 "formField": true
 },
 {
 "updatedAt": "2020-09-29T16:30:29.241Z",
 "createdAt": "2020-09-29T16:30:29.241Z",
 "name": "first_name",
 "label": "First Name",
 "type": "string",
 "fieldType": "text",
 "groupName": "users_information",
 "displayOrder": -1,
 "calculated": false,
 "externalOptions": false,
 "archived": false,
 "hasUniqueValue": false,
 "hidden": false,
 "modificationMetadata": {
 "archivable": true,
 "readOnlyDefinition": false,
 "readOnlyValue": false
 },
 "formField": false
 },
 {
 "name": "hs_all_accessible_team_ids",
 "label": "All accessible team IDs",
 "type": "enumeration",
 "fieldType": "checkbox",
 "description": "The team IDs, including up the team hierarchy, corresponding to all owner referencing properties for this object, both default and custom",
 "groupName": "users_information",
 "displayOrder": -1,
 "calculated": false,
 "externalOptions": false,
 "hasUniqueValue": false,
 "hidden": true,
 "modificationMetadata": {
 "archivable": true,
 "readOnlyDefinition": true,
 "readOnlyValue": true
 },
 "formField": false
 },
 {
 "name": "hs_created_by_user_id",
 "label": "Created by user ID",
 "type": "number",
 "fieldType": "number",
 "description": "The user that created this object. This value is automatically set by HubSpot and may not be modified.",
 "groupName": "users_information",
 "displayOrder": -1,
 "calculated": false,
 "externalOptions": false,
 "hasUniqueValue": false,
 "hidden": false,
 "modificationMetadata": {
 "archivable": true,
 "readOnlyDefinition": true,
 "readOnlyValue": true
 },
 "formField": false
 },
 {
 "name": "hs_createdate",
 "label": "Object create date/time",
 "type": "datetime",
 "fieldType": "date",
 "description": "The date and time at which this object was created. This value is automatically set by HubSpot and may not be modified.",
 "groupName": "users_information",
 "displayOrder": -1,
 "calculated": false,
 "externalOptions": false,
 "hasUniqueValue": false,
 "hidden": false,
 "modificationMetadata": {
 "archivable": true,
 "readOnlyDefinition": true,
 "readOnlyValue": true
 },
 "formField": false
 },
 {
 "name": "hs_lastmodifieddate",
 "label": "Object last modified date/time",
 "type": "datetime",
 "fieldType": "date",
 "description": "Most recent timestamp of any property update for this object. This includes HubSpot internal properties, which can be visible or hidden. This property is updated automatically.",
 "groupName": "users_information",
 "displayOrder": -1,
 "calculated": false,
 "externalOptions": false,
 "hasUniqueValue": false,
 "hidden": false,
 "modificationMetadata": {
 "archivable": true,
 "readOnlyDefinition": true,
 "readOnlyValue": true
 },
 "formField": false
 },
 {
 "name": "hs_merged_object_ids",
 "label": "Merged object IDs",
 "type": "enumeration",
 "fieldType": "checkbox",
 "description": "The list of object IDs that have been merged into this object. This value is automatically set by HubSpot and may not be modified.",
 "groupName": "users_information",
 "displayOrder": -1,
 "calculated": false,
 "externalOptions": false,
 "hasUniqueValue": false,
 "hidden": true,
 "modificationMetadata": {
 "archivable": true,
 "readOnlyDefinition": true,
 "readOnlyValue": true
 },
 "formField": false
 },
 {
 "name": "hs_object_id",
 "label": "Object ID",
 "type": "number",
 "fieldType": "number",
 "description": "The unique ID for this object. This value is automatically set by HubSpot and may not be modified.",
 "groupName": "users_information",
 "displayOrder": -1,
 "calculated": false,
 "externalOptions": false,
 "hasUniqueValue": false,
 "hidden": false,
 "modificationMetadata": {
 "archivable": true,
 "readOnlyDefinition": true,
 "readOnlyValue": true
 },
 "formField": false
 },
 {
 "name": "hs_updated_by_user_id",
 "label": "Updated by user ID",
 "type": "number",
 "fieldType": "number",
 "description": "The user that last updated this object. This value is automatically set by HubSpot and may not be modified.",
 "groupName": "users_information",
 "displayOrder": -1,
 "calculated": false,
 "externalOptions": false,
 "hasUniqueValue": false,
 "hidden": false,
 "modificationMetadata": {
 "archivable": true,
 "readOnlyDefinition": true,
 "readOnlyValue": true
 },
 "formField": false
 },
 {
 "name": "hs_user_ids_of_all_owners",
 "label": "User IDs of all owners",
 "type": "enumeration",
 "fieldType": "checkbox",
 "description": "The user IDs of all owners of this object",
 "groupName": "users_information",
 "displayOrder": -1,
 "calculated": false,
 "externalOptions": false,
 "hasUniqueValue": false,
 "hidden": true,
 "modificationMetadata": {
 "archivable": true,
 "readOnlyDefinition": true,
 "readOnlyValue": true
 },
 "formField": false
 },
 {
 "updatedAt": "2020-09-29T16:30:29.246Z",
 "createdAt": "2020-09-29T16:30:29.246Z",
 "name": "last_name",
 "label": "Last Name",
 "type": "string",
 "fieldType": "text",
 "groupName": "users_information",
 "displayOrder": -1,
 "calculated": false,
 "externalOptions": false,
 "archived": false,
 "hasUniqueValue": false,
 "hidden": false,
 "modificationMetadata": {
 "archivable": true,
 "readOnlyDefinition": false,
 "readOnlyValue": false
 },
 "formField": false
 }
 ],
 "associations": [
 {
 "fromObjectTypeId": "2-1087393",
 "toObjectTypeId": "0-48",
 "name": "user_to_call",
 "cardinality": "ONE_TO_MANY",
 "inverseCardinality": "ONE_TO_MANY",
 "id": "23",
 "createdAt": null,
 "updatedAt": null
 },
 {
 "fromObjectTypeId": "0-48",
 "toObjectTypeId": "2-1087393",
 "name": "user_to_call",
 "cardinality": "ONE_TO_MANY",
 "inverseCardinality": "ONE_TO_MANY",
 "id": "24",
 "createdAt": null,
 "updatedAt": null
 },
 {
 "fromObjectTypeId": "2-1087393",
 "toObjectTypeId": "0-47",
 "name": "user_to_meeting_event",
 "cardinality": "ONE_TO_MANY",
 "inverseCardinality": "ONE_TO_MANY",
 "id": "19",
 "createdAt": null,
 "updatedAt": null
 },
 {
 "fromObjectTypeId": "0-47",
 "toObjectTypeId": "2-1087393",
 "name": "user_to_meeting_event",
 "cardinality": "ONE_TO_MANY",
 "inverseCardinality": "ONE_TO_MANY",
 "id": "20",
 "createdAt": null,
 "updatedAt": null
 },
 {
 "fromObjectTypeId": "2-1087393",
 "toObjectTypeId": "0-46",
 "name": "user_to_note",
 "cardinality": "ONE_TO_MANY",
 "inverseCardinality": "ONE_TO_MANY",
 "id": "21",
 "createdAt": null,
 "updatedAt": null
 },
 {
 "fromObjectTypeId": "0-46",
 "toObjectTypeId": "2-1087393",
 "name": "user_to_note",
 "cardinality": "ONE_TO_MANY",
 "inverseCardinality": "ONE_TO_MANY",
 "id": "22",
 "createdAt": null,
 "updatedAt": null
 },
 {
 "fromObjectTypeId": "2-1087393",
 "toObjectTypeId": "0-51",
 "name": "user_to_conversation_session",
 "cardinality": "ONE_TO_MANY",
 "inverseCardinality": "ONE_TO_MANY",
 "id": "25",
 "createdAt": null,
 "updatedAt": null
 },
 {
 "fromObjectTypeId": "0-51",
 "toObjectTypeId": "2-1087393",
 "name": "user_to_conversation_session",
 "cardinality": "ONE_TO_MANY",
 "inverseCardinality": "ONE_TO_MANY",
 "id": "26",
 "createdAt": null,
 "updatedAt": null
 },
 {
 "fromObjectTypeId": "2-1087393",
 "toObjectTypeId": "0-49",
 "name": "user_to_email",
 "cardinality": "ONE_TO_MANY",
 "inverseCardinality": "ONE_TO_MANY",
 "id": "17",
 "createdAt": null,
 "updatedAt": null
 },
 {
 "fromObjectTypeId": "0-49",
 "toObjectTypeId": "2-1087393",
 "name": "user_to_email",
 "cardinality": "ONE_TO_MANY",
 "inverseCardinality": "ONE_TO_MANY",
 "id": "18",
 "createdAt": null,
 "updatedAt": null
 },
 {
 "fromObjectTypeId": "2-1087393",
 "toObjectTypeId": "0-27",
 "name": "user_to_task",
 "cardinality": "ONE_TO_MANY",
 "inverseCardinality": "ONE_TO_MANY",
 "id": "15",
 "createdAt": null,
 "updatedAt": null
 },
 {
 "fromObjectTypeId": "0-27",
 "toObjectTypeId": "2-1087393",
 "name": "user_to_task",
 "cardinality": "ONE_TO_MANY",
 "inverseCardinality": "ONE_TO_MANY",
 "id": "16",
 "createdAt": null,
 "updatedAt": null
 }
 ],
 "name": "users"
 }

In case anyone else runs into this, I managed to figure it out by inspecting the requests made by the importer on the Hubspot website.

For custom objects, specify “columnObjectTypeId” rather than “columnObjectType”; the value is the “objectTypeId” from your custom object.

Would it be possible to update the documentation to include more details on the import JSON format? Or perhaps that documentation already exists, and I just wasn’t able to track it down.

Thanks @nyergler ,

I have flagged this to the team :grin:

Please update the documentation. The imports API lacks code samples for the actual import endpoint. Thank you!

I’m so happy you solved this issue. I was trying to find information about this and couldn’t find it anywhere. Our Hubspot rep asked to share your solution with their developers to update their API documentation. Thanks!