Attaching multiple files to a ticket

Hi,

I am trying to attach multiple files to a ticket via API.

I uploaded the files first, got the file ID, created the ticket, and got the ticket ID—everything’s good.

For a single file, everything works well. I made a note with the properties:

type HSNoteProperties struct { HSNoteBody string json:"hs_note_body,omitempty"HSAttachmentId stringjson:"hs_attachment_ids,omitempty"HSTimestamp stringjson:“hs_timestamp,omitempty”}

To the endpoint:

"https://api.hubapi.com/crm/v3/objects/notes"

However, this does not work for multiple files. I’ve tried the same endpoint with association

{ AssociationCategory: "HUBSPOT_DEFINED", AssociationTypeID: 22,}

but this does not work, telling me the associationTypeID is wrong.

So… How can I attach multiple files to a ticket or a note? I cannot find anything up to date…

Many thanks in advance

Apologies, I don’t see how to edit my first message. However, I have noticed that there is an “attachment” section in the ticket, different from “notes.” How can I attach uploaded files to a ticket? (Is there a way to attach multiple files at once?). I couldn’t find anything in the documentation.

Hi @JcUnitag, did you ever manage to find a solution for this? I’m also trying to add an attachment to a ticket.

Hi,

Yes, in our case we create the ticket first with a post request on https://api.hubapi.com/crm/v3/objects/tickets.

Once the call succeed it’ll return a body with the ID of the ticket. We then have to do two extra steps:
- We create a note on the endpoint https://api.hubapi.com/crm/v3/objects/notes. One note per file to attach

- each note will return an id and we then attach the note to the ticket:

if withFiles == "true" {
		for _, fileID := range cST.FilesIDs {
			noteID, err := h.createAttachmentNotes(ctx, strconv.Itoa(int(fileID)))
			if err != nil {
				return "", err
			}

			if err = h.attachNoteToTicket(ctx, noteID.ID, idTicket.ID); err != nil {
				return "", err
			}
		}
	}

To attach a note to a ticket, we are using the following;

hsNotestoTicket := HSNotesToTicket{
		Inputs: []HSNotesToTicketInput{
			{TicketFrom: IDFromTO{ID: ticketID}, ToNote: IDFromTO{ID: noteID}, Type: "ticket_to_note"},
		},
	}

Sent to the endpoint: https://api.hubapi.com/crm/v3/associations/ticket/note/batch/create

It’s not very straightforward, and HubSpot makes changes faster than their doc can catch up, making the whole project really hard.

@JcUnitag - although its obscure and perhaps a bit arcane, the approach for multiple files is that the file ID values (internal values) are separated by a semicolon. You will find this works smoothly.

Steve