Find file's URL through association

Hello fellows !

I am looking to know how to find the file’s public url of an attachement put in a note, in my situation the notes are located in deals exclusively. I would like to use Operation Hub Pro’s webhook or custom code.

Is there anyway to find it easily ?

After my research, it’s look like that I need to make at least 4 api calls from deals to files, is there anyway to make it quickly ?

Thanks for your help !

Hey, @JulienD8 :waving_hand: Thanks for reaching out. Hey, @weiliang_lee @miljkovicmisa, do you have any thoughts here? I don’t know of a method that doesn’t involve multiple calls.

Best,

Jaycee

Hello @Jaycee_Lewis Thanks for the tag :waving_hand:

Hey @JulienD8 Thanks for reaching out. I am assuming you already have a particuar Deal ID and you’d want to retrieve all attachments of those notes in that deal.

Minimally we’ll need 2 api calls.

The first call would be an association to the notes using the Search Endpoint:

POST /crm/v3/objects/notes/search

The body of your request could be something like so - and the “hs_attachment_ids” property will return all files associated to that note.

{
 "properties": [ "hs_attachment_ids" ],
 "filterGroups": [
 {
 "filters": [
 {
 "operator": "EQ",
 "propertyName": "associations.deal",
 "value": "<insert deal id>"
 }
 ]
 }
 ]
}

Once you have them, then the 2nd call would be to fetch from the Files Endpoint:

GET /files/v3/files/{fileId}

Would this help in your use case?

Cheers

WL