APIs & Integrations

yorambaron
Participant

Problem with creating a note using https://api.hubapi.com/crm/v3/objects/notes

SOLVE

I want to create a note that attaches a file (in the file manager) to a company.

 

I used https://api.hubapi.com/crm/v3/objects/notes with curl following JSON object.

 

{
"associations": [
{
"types": [
{
"associationCategory": "HUBSPOT_DEFINED",
"associationTypeId": 2
}
],
"to": {
"id": "2597827578",
"type": "company"
}
}
],
"attachments": [
{
"id": "186910861670"
}
],
"properties": {
"hs_note_body": "Comment"
}
}

 

I recieved the error:

{
"context": {
"properties": [
"hs_timestamp"
]
},
"correlationId": "a3553c8c-bdac-4148-885b-20abdd9d7708",
"message": "Error creating NOTE. Some required properties were not set.",
"category": "VALIDATION_ERROR",
"status": "error"
}

 

What did I do wrong?

 

 

0 Upvotes
1 Accepted solution
MichaelMa
Solution
Contributor

Problem with creating a note using https://api.hubapi.com/crm/v3/objects/notes

SOLVE

It's noted in the context response. You're missing the required property of "hs_timestamp" (unix timestamp) in your payload.

View solution in original post

7 Replies 7
GiantFocal
Top Contributor | Gold Partner
Top Contributor | Gold Partner

Problem with creating a note using https://api.hubapi.com/crm/v3/objects/notes

SOLVE

Hi @yorambaron,

 

The error occurs because the required "hs_timestamp" parameter is missing from your JSON request.

 

To fix this issue, add the "hs_timestamp" field to the properties object in your JSON request. Your updated JSON should appear as follows:

 

{
"associations": [
{
"types": [
{
"associationCategory": "HUBSPOT_DEFINED",
"associationTypeId": 2
}
],
"to": {
"id": "2597827578",
"type": "company"
}
}
],
"attachments": [
{
"id": "186910861670"
}
],
"properties": {
"hs_note_body": "Comment",
"hs_timestamp": "1709688326000"  // Add current timestamp in milliseconds
}
}

 

Best regards,
Ernesto @ GiantFocal
Found this answer helpful?
Marking it as the solution helps both the community and me - thanks in advance!
0 Upvotes
yorambaron
Participant

Problem with creating a note using https://api.hubapi.com/crm/v3/objects/notes

SOLVE

I added "hs_timestamp" the JSON see the error message:

{
"correlationId": "0ebef994-344a-4b10-b7ad-2944a6de62b9",
"message": "invalid from object type 0-46 for associations to be created. expected: 0-2",
"category": "VALIDATION_ERROR",
"status": "error"
}

 

JSON request:

{
"associations": [
{
"types": [
{
"associationCategory": "HUBSPOT_DEFINED",
"associationTypeId": 2
}
],
"to": {
"id": "2597827578",
"type": "company"
}
}
],
"attachments": [
{
"id": "186918798705"
}
],
"properties": {
"hs_timestamp": 1735047120,
"hs_note_body": "message"
}
}

 

0 Upvotes
MichaelMa
Contributor

Problem with creating a note using https://api.hubapi.com/crm/v3/objects/notes

SOLVE

It looks your like JSON is a bit off.

 

 

 

{
    "associations": [
        {
            "to": {
                "id": "2597827578"
            },
            "types": [
                {
                    "associationCategory": "HUBSPOT_DEFINED",
                    "associationTypeId": 190
                }
            ]
        }
        ],
        "attachments": [
            {
                "id": "186918798705"
            }
        ],
        "properties": {
            "hs_note_body": "Comment",
            "hs_timestamp": 1735047120
        }
}

 

 

 

This page has a good sample JSON:

https://developers.hubspot.com/docs/guides/api/crm/engagements/notes#associations

 

For the list of associationTypeId (note to X):

https://developers.hubspot.com/docs/guides/api/crm/associations/associations-v4

yorambaron
Participant

Problem with creating a note using https://api.hubapi.com/crm/v3/objects/notes

SOLVE

In the link

the "hs_timestamp": "2021-11-12T15:48:22Z" is incorect, it should be a unix timestamp.

0 Upvotes
yorambaron
Participant

Problem with creating a note using https://api.hubapi.com/crm/v3/objects/notes

SOLVE

Thanks MichaelMa,

 

I changed the JSON and received the following error:

{"correlationId":"3fceddb8-7c41-4fb7-adfd-7253f5eca0e9","message":"invalid from object type 0-46 for associations to be created. expected: 0-2","category":"VALIDATION_ERROR","status":"error"}

 

Following is the JSON structure based on the link that you provided.

Any idea what the problem is? I find the error message challenging..

{
"associations": [
{
"types": [
{
"associationCategory": "HUBSPOT_DEFINED",
"associationTypeId": 189
}
],
"to": {
"id": 2597827578
}
}
],
"properties": {
"hs_attachment_ids": "186964207421",
"hs_timestamp": 1741259013,
"hs_note_body": "comment"
}
}

 

0 Upvotes
MichaelMa
Contributor

Problem with creating a note using https://api.hubapi.com/crm/v3/objects/notes

SOLVE

associationTypeId 189 is COMPANY to NOTE which is incorrect as you're starting from the NOTE object. NOTE to COMPANY is 190.

0 Upvotes
MichaelMa
Solution
Contributor

Problem with creating a note using https://api.hubapi.com/crm/v3/objects/notes

SOLVE

It's noted in the context response. You're missing the required property of "hs_timestamp" (unix timestamp) in your payload.