APIs & Integrations

SFu5
Participant | Platinum Partner
Participant | Platinum Partner

associate email to a record api is not working?

I am trying to associate email to a record with api, but seems not working properly, someone could help here?

https://developers.hubspot.com/docs/api/crm/email

I tried with put and post both, not working both, is there anything i did wrong? 

test error2.png

 

 

0 Upvotes
2 Replies 2
Jaycee_Lewis
Community Manager
Community Manager

associate email to a record api is not working?

Hey, @SFu5 👋 Thanks for reaching out! Can you post an example request and response for the association you are doing? Adding it using the code block tool will be helpful, but is not required. 

 

I ran a quick test in Postman:

  • I created an email and grabbed the ID
  • I used the endpoint provided in the Overview tab — Associate emails with a record 
    PUT /crm/v3/objects/emails/{emailId}/associations/{toObjectType}/{toObjectId}/{associationType}​
  • Request URL
    https://api.hubspot.com/crm/v3/objects/emails​
  • My request (I used a Private App for Authorization) 
    PUT https://api.hubspot.com/crm/v3/objects/emails/26823740672/associations/contact/451/198​
  • The response body
    {
        "id": "26823740672",
        "properties": {
            "hs_createdate": "2022-10-17T16:55:30.896Z",
            "hs_lastmodifieddate": "2022-10-17T16:55:30.896Z",
            "hs_object_id": "26823740672"
        },
        "createdAt": "2022-10-17T16:55:30.896Z",
        "updatedAt": "2022-10-17T16:55:30.896Z",
        "archived": false,
        "associations": {
            "contacts": {
                "results": [
                    {
                        "id": "451",
                        "type": "email_to_contact"
                    }
                ]
            }
        }
    }​
    CleanShot 2022-10-17 at 11.17.43.png

Thanks for the additional information! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
SFu5
Participant | Platinum Partner
Participant | Platinum Partner

associate email to a record api is not working?

Thanks so much, Joycee, I tried you way and it worked now. this is great, thanks.

0 Upvotes