APIs & Integrations

Otaka
Member

Associations when importing multiple files from the API

Hello!

I have a question on the import API.

 

I want to import using `POST /crm/crm/v3/imports` with CONTACT and DEAL associations.
And I want to do this by importing multiple files.

The common column is `email`.
But I get the following error.
Is there anything missing in the JSON?

Is it possible to associate objects in multiple files using the API?

 

CSV

スクリーンショット 2022-08-04 11.26.38.pngスクリーンショット 2022-08-04 11.26.33.png

 

JSON

 

{
  "name": "Import-contact-records-app",
  "files": [
    {
      "fileName": "contact_test.csv",
      "fileFormat": "CSV",
      "dateFormat": "YEAR_MONTH_DAY",
      "fileImportPage": {
        "hasHeader": true,
        "columnMappings": [
          {
            "ignored": false,
            "columnObjectTypeId": "0-1",
            "columnName": "lastname",
            "propertyName": "lastname",
            "idColumnType": null
          },
          {
            "ignored": false,
            "columnObjectTypeId": "0-1",
            "columnName": "email",
            "propertyName": "email",
            "idColumnType": "HUBSPOT_ALTERNATE_ID",
            "associationIdentifiedColumn": true
          },
          {
            "ignored": false,
            "columnObjectTypeId": "0-1",
            "columnName": "phone",
            "propertyName": "phone",
            "idColumnType": null
          }
        ]
      }
    },
    {
      "fileName": "deal_test.csv",
      "fileFormat": "CSV",
      "dateFormat": "YEAR_MONTH_DAY",
      "fileImportPage": {
        "hasHeader": true,
        "columnMappings": [
          {
            "ignored": false,
            "columnObjectTypeId": "0-3",
            "columnName": "payment_day",
            "propertyName": "payment_day",
            "idColumnType": null
          },
          {
            "ignored": false,
            "columnObjectTypeId": "0-3",
            "columnName": "dealname",
            "propertyName": "dealname",
            "idColumnType": null
          },
          {
            "ignored": false,
            "columnObjectTypeId": "0-3",
            "columnName": "pipeline",
            "propertyName": "pipeline",
            "idColumnType": null
          },
          {
            "ignored": false,
            "columnObjectTypeId": "0-3",
            "columnName": "dealstage",
            "propertyName": "dealstage",
            "idColumnType": null
          },
          {
            "ignored": false,
            "columnObjectTypeId": "0-3",
            "columnName": "email",
            "propertyName": null,
            "idColumnType": null,
            "foreignKeyType": {
              "associationCategory": "HUBSPOT_DEFINED",
              "associationTypeId": 4
            },
            "associationIdentifiedColumn": false
          }
        ]
      }
    }
  ]
}

 

 

ERROR MESSAGE

 

{
    "status": "error",
    "message": "column objectType ObjectTypeId{legacyObjectType=DEAL} does not match association fromObjectType AssociationDefinition{category=HUBSPOT_DEFINED, id=4, inverseId=3, fromObjectTypeId=ObjectTypeId{legacyObjectType=CONTACT}, toObjectTypeId=ObjectTypeId{legacyObjectType=DEAL}, cardinality=ONE_TO_MANY, inverseCardinality=ONE_TO_MANY, name=CONTACT_TO_DEAL, inverseName=DEAL_TO_CONTACT, hasAllAssociatedObjects=true, isPrimary=false, isInversePrimary=false, inverseHasAllAssociatedObjects=true, maxToObjectIds=10000, maxFromObjectIds=1000, hasCascadingDeletes=false}",
    "correlationId": "3abbcce4-76ab-4eed-adbc-2b3f0c8f0833"
}

 

 

POSTMAN

スクリーンショット 2022-08-04 11.30.47.png

0 Upvotes
3 Replies 3
fracca
Participant

Associations when importing multiple files from the API

@Jaycee_Lewis - Can you see if you can get an update on this? I am also having similar issues. I have 2 CSV files(Company, Custom Object). The Company file contains (RecordId, a custom unique property), and the second file contains all the Custom Objects, including a column for matching. The API documentation seems quite limited on handling multiple files with associations.

 

Thanks Scott

 

cc: @tjoyce @himanshurauthan

@Levi @DanielSanchez 

0 Upvotes
himanshurauthan
Thought Leader | Elite Partner
Thought Leader | Elite Partner

Associations when importing multiple files from the API

Hello @Jaycee_Lewis  and @Otaka

 

So @Otaka  I think your JSON needs to be updated by mentioning the idColumnType as HUBSPOT_ALTERNATE_ID and columnObjectTypeId as '0-1' as it's the email of the contact.

 

So the updated email column of the deal file will look like this -

 

{"ignored": false,"columnObjectTypeId": "0-1","columnName": "email","propertyName": null,"idColumnType": 'HUBSPOT_ALTERNATE_ID',"foreignKeyType": {"associationCategory": "HUBSPOT_DEFINED","associationTypeId": 4},"associationIdentifiedColumn": false}  

 

Regards,

 

Digital Marketing & Inbound Expert In Growth Hacking Technology
0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Associations when importing multiple files from the API

Hi, @Otaka  👋 Thanks for reaching out. Hey, @tjoyce @himanshurauthan @DanielSanchez @Levi do you have any insight you can share with @Otaka?

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes