- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 508
Salesforce
        Tim Hall edited this page Oct 10, 2015 
        ·
        3 revisions
      
    An example of using Salesforce with VBA-Web is included in the examples/ folder of this project. Some details:
- Use the instructions in Setup Salesforce to get a consumer key and secret
- Using the Username-Password OAuth Authentication Flow, use the OAuth2Authenticator and set it up as follows:
Dim Auth As New OAuth2Authenticator
Auth.Setup _
    ClientId:="ConsumerKey", _
    ClientSecret:="ConsumerSecret", _
    Username:="Username", _
    Password:="Password" & "SecurityToken"
Auth.SetupTokenUrl "https://login.salesforce.com/services/oauth2/token?grant_type=password"
Set Client.Authenticator = AuthRequests for objects (Accounts, Contacts, etc) pass through a general "sobjects" resource and therefore a generic object request can be created.
Public Function ObjectRequest(ObjectName As String, ObjectId As String) As RestRequest
    Dim Request As New WebRequest
    Request.Resource = "services/data/{ApiVersion}/sobjects/{ObjectName}/{ObjectId}"
    Request.AddUrlSegment "ApiVersion", "v26.0"
    Request.AddUrlSegment "ObjectName", ObjectName
    Request.AddUrlSegment "ObjectId", ObjectId
    Set ObjectRequest = Request
End Function
' e.g. Client.Execute(ObjectRequest("Account", "Id...12345"))The example includes details on using async methods, updating objects, and setting up an simple implementation.