api = ::Hubspot::Crm::Contacts::BasicApi.new
api.create({firstname: 'john', lastname: 'doe', email: '[email protected]'}.to_json, auth_names: 'hapikey')
请求被执行,但详细信息在 Hubspot 联系人列表中不可见,它显示没有名字、姓氏和电子邮件的空联系人。
这是当我通过 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>
我已在配置文件中正确配置了 API 密钥
尝试此操作来更新您创建的联系人:
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'})
要在 HubSpot 中创建联系人,您可以使用以下方法:
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]' }})
您可以将其他属性添加到电子邮件旁边。