CRM

TKucur
Member

how to create messages via api belonging the contact ,just created via api as well?

Hello

I researched engagements api.

I created contact from apis and can be able to view in hubspot, ver well.

my aim is , I want to create message(s) based on that contact. 

before creating message, I think, I have to create thread. after that, I have to create messages belonging that thread. but thread does not have userId(s) . 

I am little bit confused with the architecture.

could you tell me the right way to have api(s) to create the messages for the contact I have just created? 

0 Upvotes
6 Replies 6
TKucur
Member

how to create messages via api belonging the contact ,just created via api as well?

hello 

I fixed problem

 

0 Upvotes
TKucur
Member

how to create messages via api belonging the contact ,just created via api as well?

1) I created a contact via api. Success.

2) I created a note via api. Success.

3) I tried to associate note with contact, but not success.

request (HttpPut)

https://api.hubspot.com/crm/v4/objects/notes/14538348530/associations/contact/251/?hapikey=pat-eu1-8...

 

response

 

{

    "status""error",
    "message""The API key provided is invalid. View or manage your API key here: https://app.hubspot.com/l/api-key/",
    "correlationId""05fa4630-8980-4204-955d-a0959298dfbe",
    "category""INVALID_AUTHENTICATION",
    "links": {
        "api key""https://app.hubspot.com/l/api-key/"
    }
}
0 Upvotes
TKucur
Member

how to create messages via api belonging the contact ,just created via api as well?

1) I created a contact via api. Success.

2) I created a note via api. Success.

3) I tried to associate note with contact, but not success.

 

0 Upvotes
TKucur
Member

how to create messages via api belonging the contact ,just created via api as well?

I use httpput

0 Upvotes
MiaSrebrnjak
Community Manager
Community Manager

how to create messages via api belonging the contact ,just created via api as well?

Hi @TKucur,

 

Thank you for your post! 

I'll invite a couple of API experts to this conversation as I'm not very familiar with this topic myself: 

hi @coldrickjack@klloyd__1@Ismail, do you have any tips for @TKucur? Thank you! 

 

Cheers
Mia, Community Team 


Wusstest du, dass es auch eine DACH-Community gibt?
Nimm an regionalen Unterhaltungen teil, indem du deine Spracheinstellungen änderst


Did you know that the Community is available in other languages?
Join regional conversations by
changing your language settings

0 Upvotes
klloyd__1
Participant | Partner
Participant | Partner

how to create messages via api belonging the contact ,just created via api as well?

Thanks for the tag @MiaSrebrnjak 

 

Hi @TKucur , happy to try and help here.  In your original message's error response I am seeing it state "INVALID_AUTHENTICATION".  Since you're using the hapikey in your URL request, this is referring to that key being invalid.  I would first recommend following the instructions in this developer documentation to migrate your script away from using hapikeys, and instead use Private Apps.  HubSpot is sunsetting the ability to use hapikeys as authentication at the end of this month.

 

Once you've replaced the authentication method, double check that you've also included a JSON Body with your HTTP request, stating the association type and definition

 

--data '[
{
"associationCategory": "HUBSPOT_DEFINED",
"associationTypeId": 0
}
]'

To find the associationTypeId for Contacts and notes, you can use the GET Association types endpoint .