Search code examples
rubyrestoauthsalesforcedatabasedotcom-gem

How do I get write-access through Salesforce REST API?


I am currently attempting to access a salesforce.com database via Ruby and the databasedotcom-gem. I followed the readme here: https://github.com/heroku/databasedotcom

I was able to connect to the database and to access a contact, and find that contact's email. So the connection is working correctly. However, when I ran:

contact.update_attributes "Name" => "New Name"

I received the following error

ensure_expected_response': Unable to create/update fields: Name. Please check the security ?>settings of this field and verify that it is read/write for your profile or permission set. (Databasedotcom::SalesForceError)

It seems like I have read but no write access to the salesforce db. Is this an issue with how I am using oauth (of which my understanding is very basic)? Or could it be just a settings change on salesforce.com?


Solution

  • Not all fields are writable, you just happened to pick one that's not writable to do your test. the Name field on contact is a read-only compound field of the FirstName & LastName fields, if you want to change a contacts name, then you need to update the FIrstName & LastName fields, rather than the Name field.