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?

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

Hey, @SFu5 :waving_hand: 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"
     }
     ]
     }
     }
    }​
    

Thanks for the additional information! — Jaycee

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