APIs & Integrations

IKenect
Participant

Unable to create engagement associated to contact

SOLVE

Hello,
I have a case where I'm creating a contact through the crm/v3/objects/contacts endpoint. This endpoint is returning the objectId, which I'm using as a contactId to POST an engagement using this endpoint /engagements/v1/engagements

 

 

 

{
    "engagement": {
        "active": true,
        "type": "NOTE",
        "timestamp": 1664375177444
    },
    "associations": {
        "contactIds": [contactId]
    },
    "metadata": {
        "body": "a message"
    }
}

 

 

I'm receiving this error from the engagement API, and it doesn't make sense to me because the contact is being created without any issue but then I can't associate it to an engagement

 

 

{
    "status": "error",
    "message": "one or more associations are not valid",
    "correlationId": "b31bcefe-3869-4d0a-bcfd-39601a3fd272",
    "validationResults": [
        {
            "row": {
                "portalId": 6449376,
                "definition": {
                    "category": "HUBSPOT_DEFINED",
                    "id": 201,
                    "inverseId": 202,
                    "fromObjectTypeId": "0-1",
                    "toObjectTypeId": "0-46",
                    "cardinality": "ONE_TO_MANY",
                    "inverseCardinality": "ONE_TO_MANY",
                    "name": "CONTACT_TO_NOTE",
                    "inverseName": "NOTE_TO_CONTACT",
                    "label": null,
                    "inverseLabel": null,
                    "hasAllAssociatedObjects": false,
                    "isPrimary": false,
                    "isInversePrimary": false,
                    "inverseHasAllAssociatedObjects": false,
                    "maxToObjectIds": 10000,
                    "maxFromObjectIds": 1000,
                    "hasCascadingDeletes": false,
                    "toObjectType": "NOTE",
                    "fromObjectType": "CONTACT"
                },
                "fromObjectId": 35948551,
                "fromObjectTypeId": "0-1",
                "objectTypeAndId": {
                    "objectTypeId": "0-1",
                    "objectId": 35948551
                }
            },
            "result": "INVALID_FROM_OBJECT"
        }
    ],
    "errorMessages": [
        "0-1=35948551 is not a valid object"
    ]
}

 

 

 

Any kind of insight about this error will be really aprecciated.

1 Accepted solution
ChrisoKlepke
Solution
Key Advisor | Elite Partner
Key Advisor | Elite Partner

Unable to create engagement associated to contact

SOLVE

Hey @IKenect , 

 

this looks very interesting. Is there a specific reason why you're using the v1 of the engagement endpoint? Are you depending on that version for some reason? 

 

If not, I recommend using the up to date v3. With this one, you have two different endpoints for creating an engagement

/crm/v3/objects/notes

and then associating it with a contact with the noteId you get in the first response. 

/crm/v3/objects/notes/{noteId}/associations/{toObjectType}/{toObjectId}/{associationType}

 See the docs for more details here.

 

So, in total, you end up with three calls:

  • First create the contact -> Response gives you the contactId
  • Create the Note Engagement -> Response gives you the noteId
  • Tie things up with an association call

Please let me know if this helps you.

 

If you found this post helpful, consider helping others in the community to find answers faster by marking this as a solution. I'd really appreciate it. 

 

Cheers, 

Chriso

View solution in original post

2 Replies 2
ChrisoKlepke
Solution
Key Advisor | Elite Partner
Key Advisor | Elite Partner

Unable to create engagement associated to contact

SOLVE

Hey @IKenect , 

 

this looks very interesting. Is there a specific reason why you're using the v1 of the engagement endpoint? Are you depending on that version for some reason? 

 

If not, I recommend using the up to date v3. With this one, you have two different endpoints for creating an engagement

/crm/v3/objects/notes

and then associating it with a contact with the noteId you get in the first response. 

/crm/v3/objects/notes/{noteId}/associations/{toObjectType}/{toObjectId}/{associationType}

 See the docs for more details here.

 

So, in total, you end up with three calls:

  • First create the contact -> Response gives you the contactId
  • Create the Note Engagement -> Response gives you the noteId
  • Tie things up with an association call

Please let me know if this helps you.

 

If you found this post helpful, consider helping others in the community to find answers faster by marking this as a solution. I'd really appreciate it. 

 

Cheers, 

Chriso

IKenect
Participant

Unable to create engagement associated to contact

SOLVE

Thank you for the response! We should really start using the v3 endpoints for notes. 

 

But I think I have a problem with contacts, because I'm able to create them and for some strange reason, some of them are dissapearing.

The contact from the example was created on HubSpot throught the API, and then I wasn't able to fetch it by its Id, and of course, I wasn't able to post a note associated to it. Do you know what can be the cause of these dissapearances? 

Recently I was able to find out that the customer of the integration was archiving some contacts, this was causing the issue. 

I don't know how obvious it is but for anyone with the same problem, make sure that the contact is not marked as archived when associating it to an engagement through the API.