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?
It’s noted in the context response. You’re missing the required property of “hs_timestamp” (unix timestamp) in your payload.
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”
}
}
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:
For the list of associationTypeId (note to X):
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”
}
}
associationTypeId 189 is COMPANY to NOTE which is incorrect as you’re starting from the NOTE object. NOTE to COMPANY is 190.
In the link
the “hs_timestamp”: “2021-11-12T15:48:22Z” is incorect, it should be a unix timestamp.
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
}
}