APIs & Integrations

NBP
Top Contributor

Create Communication with a Contact association : "one or more associations are not valid" error

SOLVE

Hello,

 

When we create a communication via a POST to the url https://api.hubapi.com/crm/v3/objects/Communications with an association with a Contact, we have an http 400 error with this message:

 

 

 

{
    "status": "error",
    "message": "one or more associations are not valid",
    "correlationId": "c53390cb-3fdf-4e6a-b99c-2595189ec293",
    "category": "BAD_REQUEST"
}

 

 

 

Body request example with a contact ID '50870001' :

POST https://api.hubapi.com/crm/v3/objects/Communications

 

 

 

{
    "properties": {
        "hs_communication_channel_type": "SMS",
        "hs_communication_logged_from": "CRM",
        "hs_communication_body": "Test",
        "hs_timestamp": 1680605576883
    },
    "associations": [{
            "to": {
                "id": "50870001"
            },
            "types": [{
                    "associationCategory": "HUBSPOT_DEFINED",
                    "associationTypeId": 81
                }
            ]
        }
    ]
}

 

 

 

What does this error mean?

0 Upvotes
1 Accepted solution
Jaycee_Lewis
Solution
Community Manager
Community Manager

Create Communication with a Contact association : "one or more associations are not valid" error

SOLVE

Hey, @NBP 👋 Thanks for reaching out. That error typically indicates an incorrect or mismatched 

associationTypeId. 
 
Two things,
you can always verify the associationTypeId with this endpoint 
GET /crm/v4/associations/{fromObjectType}/{toObjectType}/labels

I tried a variation of your example and received a successful response.
 
Example:
POST https://api.hubapi.com/crm/v3/objects/communications

Request body:

{
    "properties": {
        "hs_communication_channel_type": "SMS",
        "hs_communication_logged_from": "CRM",
        "hs_communication_body": "Test. Test. Test.",
        "hs_timestamp": "2022-11-12T15:48:22Z"
    },
    "associations": [
        {
            "to": {
                "id": 1601
            },
            "types": [
                {
                    "associationCategory": "HUBSPOT_DEFINED",
                    "associationTypeId": 81
                }
            ]
        }
    ]
}

Response:

{
    "id": "33289576495",
    "properties": {
        "hs_body_preview": "Test. Test. Test.",
        "hs_body_preview_html": "<html>\n <head></head>\n <body>\n Test. Test. Test.\n </body>\n</html>",
        "hs_body_preview_is_truncated": "false",
        "hs_communication_body": "Test. Test. Test.",
        "hs_communication_channel_type": "SMS",
        "hs_communication_logged_from": "CRM",
        "hs_createdate": "2023-04-04T21:20:06.134Z",
        "hs_lastmodifieddate": "2023-04-04T21:20:06.134Z",
        "hs_object_id": "33289576495",
        "hs_timestamp": "2022-11-12T15:48:22Z"
    },
    "createdAt": "2023-04-04T21:20:06.134Z",
    "updatedAt": "2023-04-04T21:20:06.134Z",
    "archived": false
}

 

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

View solution in original post

0 Upvotes
1 Reply 1
Jaycee_Lewis
Solution
Community Manager
Community Manager

Create Communication with a Contact association : "one or more associations are not valid" error

SOLVE

Hey, @NBP 👋 Thanks for reaching out. That error typically indicates an incorrect or mismatched 

associationTypeId. 
 
Two things,
you can always verify the associationTypeId with this endpoint 
GET /crm/v4/associations/{fromObjectType}/{toObjectType}/labels

I tried a variation of your example and received a successful response.
 
Example:
POST https://api.hubapi.com/crm/v3/objects/communications

Request body:

{
    "properties": {
        "hs_communication_channel_type": "SMS",
        "hs_communication_logged_from": "CRM",
        "hs_communication_body": "Test. Test. Test.",
        "hs_timestamp": "2022-11-12T15:48:22Z"
    },
    "associations": [
        {
            "to": {
                "id": 1601
            },
            "types": [
                {
                    "associationCategory": "HUBSPOT_DEFINED",
                    "associationTypeId": 81
                }
            ]
        }
    ]
}

Response:

{
    "id": "33289576495",
    "properties": {
        "hs_body_preview": "Test. Test. Test.",
        "hs_body_preview_html": "<html>\n <head></head>\n <body>\n Test. Test. Test.\n </body>\n</html>",
        "hs_body_preview_is_truncated": "false",
        "hs_communication_body": "Test. Test. Test.",
        "hs_communication_channel_type": "SMS",
        "hs_communication_logged_from": "CRM",
        "hs_createdate": "2023-04-04T21:20:06.134Z",
        "hs_lastmodifieddate": "2023-04-04T21:20:06.134Z",
        "hs_object_id": "33289576495",
        "hs_timestamp": "2022-11-12T15:48:22Z"
    },
    "createdAt": "2023-04-04T21:20:06.134Z",
    "updatedAt": "2023-04-04T21:20:06.134Z",
    "archived": false
}

 

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes