APIs & Integrations

titusrobyk
Participant

POST /crm/v3/objects/contacts

SOLVE

Dear Community Members,
My usecase is to create a contact by using the POST /crm/v3/objects/contacts API
Addendum : We have a website and  have a Newsletter Subscription section in our website. So i would like to employee  POST /crm/v3/objects/contacts API to be invoked whenever a user enters his/her email Id in our form present in the Website.

So far i have an hapikey
Performed a test call using the following 

POST https://api.hubapi.com/crm/v3/objects/contacts?hapikey={{hapikey}}

{
  "properties": [
    {
      "property": "firstname",
      "value": "Alice"
    },
    {
      "property": "lastname",
      "value": "Test"
    },
    {
      "property": "email",
      "value": "alice-test@hubspot.com"
    }
]
}


Resposne that i am getting is as follows

{
    "status": "error",
    "message": "Invalid input JSON on line 2, column 17: Cannot deserialize instance of `java.util.LinkedHashMap` out of START_ARRAY token",
    "correlationId": "cdd965ea-51ca-4c4a-b9e6-5c598e72b564"
}
 
Could someone assist me by letting me know , what am i doing wrong here ?

Thanks
Titus



1 Accepted solution
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

POST /crm/v3/objects/contacts

SOLVE

Hey @titusrobyk,

 

When looking to use the CRM v3 API | Contacts, the POST body format should be something like this:

 

{
  "properties": {
    "firstname": "Alice",
    "lastname": "Test",
    "email": "alice-test@hubspot.com"
  }
}

The POST body format that you're currently using is only supported on the Contacts v1 API.

View solution in original post

4 Replies 4
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

POST /crm/v3/objects/contacts

SOLVE

Hey @titusrobyk,

 

When looking to use the CRM v3 API | Contacts, the POST body format should be something like this:

 

{
  "properties": {
    "firstname": "Alice",
    "lastname": "Test",
    "email": "alice-test@hubspot.com"
  }
}

The POST body format that you're currently using is only supported on the Contacts v1 API.

titusrobyk
Participant

POST /crm/v3/objects/contacts

SOLVE

Thank you Wendy , I was able to run the API
But i have another query
Annotation 2020-08-12 131512.jpg
How do i use the property names in api request payload ?
Is there a link in which i could lookup ?
i tried using contact_owner , reponse says its not present 

0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

POST /crm/v3/objects/contacts

SOLVE

Hey @titusrobyk,

 

When looking to set the contact owner via the contact v3 endpoint, you'd need to use the property internal name and in this case, the contact owner property internal name is hubspot_owner_id

 

You can retrieve property internal name by going to:

Settings > Properties > Search for the property i.e. contact owner > Hover over and click 'Edit'

 

Edit.png

 

Beside the property name, click on '</>' and you should be able to see the internal name:

Screen Shot 2020-08-13 at 1.21.33 PM.png

titusrobyk
Participant

POST /crm/v3/objects/contacts

SOLVE

@WendyGoh  Once again , Thanks alot !!

0 Upvotes