# Associate files to custom object attachment

**URL:** <https://community.hubspot.com/t/associate-files-to-custom-object-attachment/65373>\
**Category:** APIs & Integrations\
**Tags:** sdk\
**Created:** [September 19, 2022, 3:29pm UTC](https://community.hubspot.com/t/associate-files-to-custom-object-attachment/65373 "2022-09-19T15:29:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brik](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/brik/32/196404_2.png) [@Brik](https://community.hubspot.com/u/Brik)\
**Post date:** [September 19, 2022, 3:29pm UTC](https://community.hubspot.com/t/associate-files-to-custom-object-attachment/65373/1 "2022-09-19T15:29:27Z")

</div>

Hi,

I am trying to link files uploaded throught the API with my “assets” custom objects.

My upload went well and I can see my files in Hubspot.

First I tried this way, it worked for contactIds and my file is now link to my test contact, I can see the file in my contact attachments on Hubspot.

So I tried to also add the “assetsIds” but it didn’t worked for this association.

 ![Capture d’écran 2022-09-19 à 16.57.45.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/6/e/6e3b2973a1133d20bba691ee5ddb3eb781f1ddcd.png)

Here is the response, we can see in associations that I don’t have my “assets” custom object.

So instead I tried this way but I am getting a 415 ‘Unsupported Media Type’ (I also tried with the v3)

 ![Capture d’écran 2022-09-19 à 17.15.03.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/9/7/97d5d5bb88341e76f07993f1cec3496e84accbc2.png)

I am a bit confused, I tried to look into differents posts here and I read the documentation about engagement, associations and custom objects but I can’t figure out how to link my files to my custom objects attachment. Hopefully you can help me !

Thanks !

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [September 21, 2022, 6:42pm UTC](https://community.hubspot.com/t/associate-files-to-custom-object-attachment/65373/2 "2022-09-21T18:42:16Z")

</div>

Hey, @Brik 👋 Thanks for reaching out. I’ve done this a few times now and always find it a bit mysterious.

Here’s my quick test:

- I created a note and grabbed the ID 25906880309

- I have a test custom object called Boats

- I grabbed the objectType and objectID  
Type — 2-7913954  
ID — 1976776222

- I used this endpoint — Associate a note with another object  
`PUT /crm/v3/objects/notes/{noteId}/associations/{toObjectType}/{toObjectId}/{associationType}​`

- Request

- Response

- Success!

 ![note1.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/2/4/24d762ae8229196c84295182546a2960b294ab09.png)

I hope this helps get you moving in the right direction. Have fun building! — Jaycee

---

<div class="post-metadata">

**Author:** ![JMadrone](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@JMadrone](https://community.hubspot.com/u/JMadrone)\
**Post date:** [June 12, 2023, 2:15pm UTC](https://community.hubspot.com/t/associate-files-to-custom-object-attachment/65373/3 "2023-06-12T14:15:02Z")

</div>

For anyone that finds this post in the future, this app solves for this kind of thing natively in the UI using workflow actions: [HubSpot Marketplace](https://ecosystem.hubspot.com/marketplace/apps/marketing/data-management/file-attachment-associations-1549105)  
While not the actual code necessary to do this, the app solves teh use case of attaching files to objects.
