Associating note with ticket

So I’m creating ticket and uploading file by API, exactly with hubspot-api-client package. Then I want to associate them together by note. Note has been created with hs_attachment_ids to uploaded file and association to ticket. But when I’m checking ticket out at HubSpot UI, no note or file is attached. API responds with success, I can get note back.

Hey @DDobkowski,

What does the system respond with if you make a request like this?

GET https://api.hubapi.com/crm/v3/objects/notes/{NOTE_ID}?properties=hs_attachment_ids

For instance when I make the request above for a note I see the following:

{
 "results": [
 {
 "id": "19529202369",
 "properties": {
 "hs_attachment_ids": "76894753722",
 "hs_createdate": "2023-08-16T09:24:15.453Z",
 "hs_lastmodifieddate": "2023-08-16T09:24:15.453Z",
 "hs_object_id": "19529202369"
 },
 "createdAt": "2023-08-16T09:24:15.453Z",
 "updatedAt": "2023-08-16T09:24:15.453Z",
 "archived": false
 }
 ]
}

The value in “hs_attachment_ids” represents the ID of a file uploaded to the file manager in HubSpot. The reason I am asking to check this is to make sure that the attachment is correctly setup. Also, when you view the ticket can you see the note on the timeline of the record?

@coldrickjack ID of attachment is right. Also, there is no action at ticket timeline.

Thanks for sharing @DDobkowski. When you go to the Ticket Timeline do you see the note with attachment i.e something similar to the below:

If you don’t then whilst the note has been created successfully the association to the ticket record has not. In the example above I used a request as follows to create the note with attachment and associate to ticket:

POST https://api.hubapi.com/crm/v3/objects/notes
BODY
{
 "properties": {
 "hs_timestamp": "2023-08-30T16:20:00.000Z",
 "hs_note_body": "Created via the API",
 "hubspot_owner_id": "1147024111",
 "hs_attachment_ids": "78235742693"
 },
 "associations": [
 {
 "to": {
 "id": "1685582803"
 },
 "types": [
 {
 "associationCategory": "HUBSPOT_DEFINED",
 "associationTypeId": 228
 }
 ]
 }
 ]
}

RESPONSE
{
 "id": "19852901360",
 "properties": {
 "hs_all_owner_ids": "1147024111",
 "hs_attachment_ids": "78235742693",
 "hs_body_preview": "Created via the API",
 "hs_body_preview_html": "<html>\n <head></head>\n <body>\n Created via the API\n </body>\n</html>",
 "hs_body_preview_is_truncated": "false",
 "hs_createdate": "2023-08-30T15:19:59.971Z",
 "hs_lastmodifieddate": "2023-08-30T15:19:59.971Z",
 "hs_note_body": "Created via the API",
 "hs_object_id": "19852901360",
 "hs_object_source": "INTEGRATION",
 "hs_object_source_id": "1914406",
 "hs_timestamp": "2023-08-30T16:20:00Z",
 "hs_user_ids_of_all_owners": "4592290",
 "hubspot_owner_assigneddate": "2023-08-30T15:19:59.971Z",
 "hubspot_owner_id": "1147024111"
 },
 "createdAt": "2023-08-30T15:19:59.971Z",
 "updatedAt": "2023-08-30T15:19:59.971Z",
 "archived": false
}

Note how I include an associations array, within I specify the ID of the ticket in the CRM and I also specify the associationTypeId which is 228 (Note to Ticket).

Hope this helps!

Here is my timeline.
POST example is same as my request.

properties={
 "hs_timestamp": "2023-08-30T15:54:43.890Z",
 "hs_attachment_ids": "",
 "hs_note_body": "attachment"
}
associations=[
 {
 "to": {
 "id": ""
 },
 "types": [
 {
 "associationCategory": "HUBSPOT_DEFINED",
 "associationTypeId": 228
 }
 ]
 }
]
note_input = SimplePublicObjectInputForCreate(properties=properties, associations=associations)
api_response = self.client.crm.objects.notes.basic_api.create(simple_public_object_input_for_create=note_input)

Are you using the Python client? If so it could be that the “SimplePublicObjectInputForCreate” is the issue as this class is no longer publicly available. See this thread here.

It doesn’t seem like an issue with that class, because I tested with simple requests.post() method. The same issue appeared, note is created but not associated with ticket. Here is response

{
 "id": "",
 "properties": {
 "hs_attachment_ids": "",
 "hs_body_preview": "Test attachment",
 "hs_body_preview_html": "<html>\n <head></head>\n <body>\n Test attachment\n </body>\n</html>",
 "hs_body_preview_is_truncated": "false",
 "hs_createdate": "2023-08-31T09:34:49.983Z",
 "hs_lastmodifieddate": "2023-08-31T09:34:49.983Z",
 "hs_note_body": "Test attachment",
 "hs_object_id": "",
 "hs_object_source": "INTEGRATION",
 "hs_object_source_id": "",
 "hs_timestamp": "2023-08-31T09:34:49.608Z"
 },
 "createdAt": "2023-08-31T09:34:49.983Z",
 "updatedAt": "2023-08-31T09:34:49.983Z",
 "archived": False
}

From my end using Python requests works just fine, the script below creates the note and associates to a ticket in the CRM.

import requests
import json

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

payload = json.dumps({
 "properties": {
 "hs_timestamp": "2023-08-31T10:45:00.000Z",
 "hs_note_body": "Created via the API",
 "hubspot_owner_id": "1147024111",
 "hs_attachment_ids": "78235742693"
 },
 "associations": [
 {
 "to": {
 "id": "1685582803"
 },
 "types": [
 {
 "associationCategory": "HUBSPOT_DEFINED",
 "associationTypeId": 228
 }
 ]
 }
 ]
})
headers = {
 'Content-Type': 'application/json',
 'Authorization': 'Bearer pat-eu1-********-****-****-****-************'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Response:

{
 "id": "19882503621",
 "properties": {
 "hs_all_owner_ids": "1147024111",
 "hs_attachment_ids": "78235742693",
 "hs_body_preview": "Created via the API",
 "hs_body_preview_html": "<html>\n <head></head>\n <body>\n Created via the API\n </body>\n</html>",
 "hs_body_preview_is_truncated": "false",
 "hs_createdate": "2023-08-31T09:46:04.403Z",
 "hs_lastmodifieddate": "2023-08-31T09:46:04.403Z",
 "hs_note_body": "Created via the API",
 "hs_object_id": "19882503621",
 "hs_object_source": "INTEGRATION",
 "hs_object_source_id": "1914406",
 "hs_timestamp": "2023-08-31T10:45:00Z",
 "hs_user_ids_of_all_owners": "4592290",
 "hubspot_owner_assigneddate": "2023-08-31T09:46:04.403Z",
 "hubspot_owner_id": "1147024111"
 },
 "createdAt": "2023-08-31T09:46:04.403Z",
 "updatedAt": "2023-08-31T09:46:04.403Z",
 "archived": false
}

Output:

That’s exactly how I tested it. The only difference is that I’m not giving “hubspot_owner_id”, but it’s optional. I’m starting to thinking that it’s some internal hubspot problem or something is wrong with setup of private app.

Funny thing. I made a request to get this ticket associations. It looks like there are some, but I can’t see them at ticket panel.

{
 "results": [
 {
 "toObjectId":,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 227,
 "label": None
 }
 ]
 },
 {
 "toObjectId":,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 227,
 "label": None
 }
 ]
 },
 {
 "toObjectId":,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 227,
 "label": None
 }
 ]
 },
 {
 "toObjectId":,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 227,
 "label": None
 }
 ]
 },
 {
 "toObjectId":,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 227,
 "label": None
 }
 ]
 },
 {
 "toObjectId":,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 227,
 "label": None
 }
 ]
 },
 {
 "toObjectId":,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 227,
 "label": None
 }
 ]
 },
 {
 "toObjectId":,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 227,
 "label": None
 }
 ]
 },
 {
 "toObjectId":,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 227,
 "label": None
 }
 ]
 },
 {
 "toObjectId":,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 227,
 "label": None
 }
 ]
 },
 {
 "toObjectId":,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 227,
 "label": None
 }
 ]
 },
 {
 "toObjectId":,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 227,
 "label": None
 }
 ]
 },
 {
 "toObjectId":,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 227,
 "label": None
 }
 ]
 },
 {
 "toObjectId":,
 "associationTypes": [
 {
 "category": "HUBSPOT_DEFINED",
 "typeId": 227,
 "label": None
 }
 ]
 }
 ]
}

And here is response:

{"archived": False,
"archived_at": None,
"created_at": datetime.datetime(2023, 8, 30, 15, 54, 44, 273000, tzinfo=tzlocal()),
"id": "",
"properties": {"hs_attachment_ids": "",
 "hs_body_preview": "attachment",
 "hs_body_preview_html": "<html>\n"
 " <body>\n"
 " attachment\n"
 " </body>\n"
 "</html>",
 "hs_body_preview_is_truncated": "false",
 "hs_createdate": "2023-08-30T15:54:44.273Z",
 "hs_lastmodifieddate": "2023-08-30T15:54:44.273Z",
 "hs_note_body": "attachment",
 "hs_object_id": "",
 "hs_object_source": "INTEGRATION",
 "hs_object_source_id": "",
 "hs_timestamp": "2023-08-30T15:54:43.890Z"},
"properties_with_history": None,
"updated_at": datetime.datetime(2023, 8, 30, 15, 54, 44, 273000, tzinfo=tzlocal())}

And here is the result:

{"archived": False,
"archived_at": None,
"created_at": "2023-08-30T15:54:44.273Z",
"id": "",
"properties": {"hs_attachment_ids": "",
 "hs_body_preview": "attachment",
 "hs_body_preview_html": "<html>\n"
 " <body>\n"
 " attachment\n"
 " </body>\n"
 "</html>",
 "hs_body_preview_is_truncated": "false",
 "hs_createdate": "2023-08-30T15:54:44.273Z",
 "hs_lastmodifieddate": "2023-08-30T15:54:44.273Z",
 "hs_note_body": "attachment",
 "hs_object_id": "",
 "hs_object_source": "INTEGRATION",
 "hs_object_source_id": "",
 "hs_timestamp": "2023-08-30T15:54:43.890Z"},
"properties_with_history": None,
"updated_at": "2023-08-30T15:54:44.273Z"}

I can’t paste result because of some “spam” filter.

{
 "id": "",
 "properties": {
 "hs_attachment_ids": "",
 "hs_createdate": "2023-08-30T13:59:28.834Z",
 "hs_lastmodifieddate": "2023-08-30T13:59:28.834Z",
 "hs_object_id": ""
 },
 "createdAt": "2023-08-30T13:59:28.834Z",
 "updatedAt": "2023-08-30T13:59:28.834Z",
 "archived": false
}

I had to delete ids to be able to paste result