Reputation: 63
api = ::Hubspot::Crm::Contacts::BasicApi.new
api.create({firstname: 'john', lastname: 'doe', email: '[email protected]'}.to_json, auth_names: 'hapikey')
The request gets executed, but the details are not visible on Hubspot contactlist, It shows empty contact without firstname, lastname and email.
Here is the response, when I fetch the details by contact_id
<Hubspot::Crm::Contacts::SimplePublicObjectWithAssociations:0x000055d0bc6ad2a8
@archived=false,
@created_at=Fri, 11 Mar 2022 12:52:44 +0000,
@id="456501",
@properties=
{"createdate"=>"2022-03-11T12:52:44.492Z",
"email"=>"",
"firstname"=>"",
"hs_object_id"=>"456501",
"lastmodifieddate"=>"2022-03-11T12:53:01.375Z",
"lastname"=>""},
@updated_at=Fri, 11 Mar 2022 12:53:01 +0000>
I have configured the API key in config file properly
Upvotes: 1
Views: 1131
Reputation: 29
To create a contact in HubSpot, you can use the following approach:
client = Hubspot::Client.new(access_token: ENV.fetch('HUBSPOT_TOKEN', nil))
client.crm.contacts.basic_api.create(simple_public_object_input: { properties: {email: '[email protected]' }})
You can include additional properties by adding them alongside the email.
Upvotes: 0
Reputation: 2203
Try this to update you created contact :
basic_api = ::Hubspot::Crm::Contacts::BasicApi.new
contact_input = ::Hubspot::Crm::Contacts::SimplePublicObjectInput.new(properties: @properties) # your properties
basic_api.update(contact_id, contact_input, { auth_names: 'hapikey'})
Upvotes: 0