I am using Notes API
Goal to create a new Note with the uploaded document ID as an attachment:
- Document ID: [ID]
- Owner ID: [ID] (myself)
- Company Object ID: [ID]
curl --request POST \
--url https://api.hubapi.com/crm/v3/objects/notes \
--header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
--header 'content-type: application/json' \
--data '{
"properties": {
"hs_timestamp": "2023-07-07T20:41:10Z",
"hs_note_body": "TEST NOTE",
"hs_attachment_ids": "[ID]",
"hubspot_owner_id": "[ID]"
},
"associations": [
{
"to": {
"id": "[ID]"
},
"types": [
{
"associationCategory": "HUBSPOT_DEFINED",
"associationTypeId": 2
}
]
}
]
}'
Returns this error response, and I have no clue what it means:
HTTP 400
{
"status": "error",
"message": "invalid from object type 0-46 for associations to be created. expected: 0-2",
"correlationId": "[ID]",
"category": "VALIDATION_ERROR"
}
Hi @jeff00seattle
The error response you received indicates that there is an issue with the association object type specified in your request. Let’s break down the error message and suggest a possible solution:
Error: “invalid from object type 0-46 for associations to be created. expected: 0-2”
This error message suggests that the “from object type” you specified for the association is invalid. The expected range for the “from object type” is between 0 and 2.
To resolve this issue, you should ensure that you are providing the correct object type in the association. Based on the code you provided, it appears you are trying to associate the note with a company object. The correct object type for a company in HubSpot is 1.
Here’s an updated version of the request with the correct object type for the association:
```curl
curl --request POST \
--url https://api.hubapi.com/crm/v3/objects/notes \
--header ‘authorization: Bearer YOUR_ACCESS_TOKEN’ \
--header ‘content-type: application/json’ \
--data ‘{
“properties”: {
“hs_timestamp”: “2023-07-07T20:41:10Z”,
“hs_note_body”: “TEST NOTE”,
“hs_attachment_ids”: “[ID]”,
“hubspot_owner_id”: “[ID]”
},
“associations”: [
{
“to”: {
“id”: “[ID]”,
“type”: “COMPANY”
}
}
]
}’
```
In this updated request, the association object now includes the correct type `“type”: “COMPANY”`.
Make sure to replace `[ID]` with the appropriate values for the document ID, owner ID, and company object ID in the request.
By making these adjustments, you should be able to create a new note with the uploaded document ID as an attachment associated with the specified company object.
Hope this will helps you out. Please mark it as Solution Accepted & Upvote to help other Community member.
Thanks!