如何使用 restforce gem 从 rails 应用程序向 salesforce 添加联系人?

How to add contact from a rails app to salesforce using restforce gem?

我正在使用 restforce gem 连接到 salesforce api。我已成功连接到它并使用 username/password 初始化客户端,如下所示

client = Restforce.new :username => 'foo',
  :password       => 'bar',
  :security_token => 'security token',
  :client_id      => 'client_id',
  :client_secret  => 'client_secret'

我可以使用 gem 文档

中给出的命令在 saleforce 中创建帐户
client.create('Account', Name: 'Foobar Inc.')

现在我想知道如何创建联系人?我试过了

client.create('Contact', Email: 'demo@example.com')

但它 returns 错误。

我试过了

client.create!('Contact', Email: 'demo@example.com')

向我显示了姓氏是评论中指定的必填字段的错误。

所以解决方案是指定 LastName,如下所示:

client.create('Contact', Email: 'demo@example.com', LastName: 'Bar')

谢谢,编码愉快。