How do I make Salesforce APIs more consumable with Apigee?

Former Community Member
Not applicable
6 8 4,803

I run into Salesforce a lot these days, if you happen to be their customer, listen in. The next question then is how can Apigee help enable delightful & consumable APIs on top of Salesforce & API enable back-end systems to be accessible from Salesforce.

The question then is more importantly what are some of the benefits of doing that. Some of those benefits include providing end-to-end visibility into your Salesforce API usage, controlling and managing the several Salesforce Platform Limits and providing consistent security / transformation to support a variety of apps in your enterprise that need access to Salesforce data.

As you may be aware, Salesforce has a lot of different APIs, REST API, SOAP API, Chatter REST API, Bulk API etc.

There are fundamentally 2 different approaches to integrating with Salesforce from Apigee:

  • Using Service Callouts: This is where you will primarily use Service Callout policy to authenticate with Salesforce login/token endpoint, get an access token from them and start interacting with their REST API to do CRUD on standard (Account, Opportunity...etc) and custom objects. (The sample attached SalesforceAccount Proxy API bundle shows you how to do this approach. It assumes you have a Salesforce account (if not you can sign up here) and an Apigee account (if not, you can sign up here). You do need to create a KeyValue Map called "sfdc_creds" in the environment you deploy your proxy to for this to work. To do that you can use the management APIs:
Issue a POST request to <a href="https://api.enterprise.apigee.com/v1/organizations/{your-org-name}/environments/{your-env-name}/keyvaluemaps">https://api.enterprise.apigee.com/v1/organizations/{your-org-name}/environments/{your-env-name}/keyvaluemaps</a>

{   
 "name" : "sfdc_creds",
 "entry" : [ 
  {
   "name" : "username",
   "value" : "---your salesforce user name---"
  },
  {
   "name" : "password",
   "value" : "---your salesforce password + security token (without any spaces)---"
  } ,
  {
   "name" : "client_id",
   "value" : "---your client id from the connected app you create in sfdc---"
  } ,
  {
   "name" : "client-secret",
   "value" : "---your client secret from the connected app you create in sfdc--"
  } 
 ]
}

You need to create a connected app in Salesforce.

  • Using Volos Salesforce Connector: The Volos Salesforce connector is a Node.js module that lets you fetch data from Salesforce using a RESTful API. It is one of the Volos Node.js modules from Apigee.

The module maps Salesforce SOQL queries to RESTful API resources and query parameters. For example, a properly configured Salesforce connector might map a SOQL query like this:

SELECT id, Owner.Name FROM Opportunity WHERE Owner.Email='jdoe@example.com'

to a RESTful API that you could call like this:

curl <a href="http://localhost:9009/opportunity?ownerEmail=jdoe@example.com">http://localhost:9009/opportunity?ownerEmail=jdoe@example.com</a>

and which might generate a JSON response like this:

{
    "action": "GET",
    "params": {
        "qp": {}
    },
    "path": "/opportunity",
    "url": "/opportunity",
    "data": [
   {
        "attributes": {
            "type": "Opportunity",
            "url": "/services/data/v2.0/sobjects/Opportunity/05555555XcYHJ3"
        },
        "Id": "00670000XcYHJ3",
        "Owner": {
            "attributes": {
                "type": "User",
                "url": "/services/data/v2.0/sobjects/User/0057555555J12"
            },
            "Name": "John Doe"
        }
    },
 ...
],
    "targetMetadata": {},
    "timestamp": 1406156417290,
    "duration": 2888,
    "applicationName": "volos-salesforce",
    "count": 100,
    "sql": "SELECT id, Owner.Name FROM Opportunity LIMIT 100"
}

The SOQL-to-REST mapping is enabled by simple JSON configuration. Here is a sample:

    'opportunity': {
        queryStringBasic: 'SELECT id, Owner.Name FROM Opportunity',
        queryStringExpanded: 'SELECT id, AccountId, Account.Name, RecordType.Name, Owner.Name, Owner.Email FROM Opportunity',
        idName: 'id',
        queryParameters: {
            lastDays: 'lastmodifieddate=LAST_N_DAYS: {lastDays}',
            accountName: 'Account.Name = \'{accountName}\'',
            ownerName: 'Owner.Name = \'{ownerName}\'',
            ownerEmail: 'Owner.Email = \'{ownerEmail}\''
        }
    }

This is modeled in the SalesforceQuery Proxy API bundle.

I have attached the 2 API bundles.

salesforceaccount-rev1-2015-04-29.zipsalesforceaccount-rev1-2015-04-29.zip

Check out this end-to-end video recording of the demo if interested.

Comments
Former Community Member
Not applicable

Here is the link to the end-to-end video recording of the demo if interested.

surbhi_nijhara
New Member

Hi,

Both bundles are of SalesforceAccount only. Could you please share bundle of SalesforceQuery.

Thanks,

Not applicable

Hi ,

I tried SalesforceAccount bundle. But I have error : Invalid cache resource reference sf-token-cache in Step definition LookupCacheCheckIfAccessTokenExists. Context Revision:1;APIProxy:SalesforceAccount;

Do you know why ?

what is difference between 2 bundle ?

thanks.

Not applicable

@Prithpal Bhogill Can you please also add the SalesforceQuery bundle. It seems both the links are for the SalesforceAccount bundle. Thanks!

Not applicable
@pbhogill

There is a wide interest on the SalesforceQuery, can you add or point to the SalesforceQuery bundle.

Much Appreciated!

Not applicable

There is this image from Egypt that you can see here. It is some sort of building or fort but I cannot figure it out with such information. I needed assignment help uk. At least the uploaded added a few things about it so people would find it easy to travel and visit it.

santhoshkumaral
New Member

@pbhogill

Can you please share the SalesforceQuery bundle. as well as am facing chalnges to deploy the provided bundle.

error is :

Invalid cache resource reference sf-token-cache in Step definition LookupCacheCheckIfAccessTokenExists. Context

thomasmarsden
Bronze 1
Bronze 1

For making Salesforce APIs more consumable with Apigee you need to contact with Masters Dissertation Help for best making salesforce.

Version history
Last update:
‎04-29-2015 10:24 AM
Updated by:
Former Community Member