Skip to Content
Technical Articles

OpenConnectors-SalesForce Integration made simple with SAP CPI & SAP CP-OCN

Introduction:

In below blog, I would like to share how we can integrate SalesForce Sales Cloud with third party (HTTPS) using SAP CPI & SAP Cloud Platform Open Connectors service.

Scenario: Third Party will make a call to CPI using HTTPS and CPI will get the Accounts data from Salesforce using Open Connectors.

Configuration in SalesForce:

Step 1:  Go to Setup –> PLATFORM TOOLS –> Apps  — > App Manager –> New Connected App

Step 2: Provide the Basic Information

Provide below details:

Enable OAuth Settings

Callback URL: https://auth.cloudelements.io/oauth

Scope:

Full Access (full)
Perform requests on your behalf at any time (refresh_token, offline_access)

Click Save and then open the App again to get the Consumer key and Secret.

SAP Open Connector Configuration

Login to SAP Cloud Platform and launch Open Connectors service.Search for Salesforce Sales Cloud and click on authenticate

Fill all the required details like below ( API Key,Secret and Endpoint Address) and click on Create Instance.

Now you are successfully connected to SalesForce with below message and click on API Docs.

Go to API Docs and click on Try it out and execute it.

Navigate to response to copy the credentials and endpoint url to be used in SAP CPI.

SAP CPI Configuration:

Lets create an iflow to make a call from third party (HTTPS) and connect to OpenConnectors endpoint url, get the accounts and send it back to third Party.

Step 1: Configure the Sender HTTPS communication channel.

Step 2: Add a script to get the Secure Parameters and set it in message property.

import com.sap.it.api.ITApi
import com.sap.it.api.ITApiFactory
import com.sap.it.api.securestore.*;
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;

def Message processData(Message message) {
    //Body 
       def body = message.getBody();
       String password;
        String _output="";
       def service = ITApiFactory.getApi(SecureStoreService.class, null);
        def credential = service.getUserCredential("SalesForce"); 
        if (credential == null)
        { throw new IllegalStateException("No credential found for alias 'SalesForce'"); 
            
        }
        else{
            password= new String(credential.getPassword());
            }
        message.setProperty("P_Password", password);
       return message;
}

 

Step 3: Set the Headers in Content Modifier

Step 4: Configure the HTTP communication Channel in Request/Reply.

 

Step 5: Deploy the Secure Parameters in the Security Material under User Credentials.

Now you can deploy the Iflow.

Testing and Result:

Take the HTTPS Endpoint from the CPI and use the postman client tool to make a Get request.

2 Comments
You must be Logged on to comment or reply to a post.
  • Hi Vikas,

    Thanks for the article and for mentioning the connection between SAP CPI and Postman. I tried to replicate the steps and had some issues in connecting the SAP CPI endpoint to postman client tool to make a Get request. Could you please elaborate on the details of this step – such as what to mention under Type, Headers, Access token etc?

    Looking forward to your response.

    Thanks,
    Shreyasee

  • Hi Vikas,

    Great article. Thanks for sharing it.

    I have got a question: even following all the steps suggested by you above, when I tried to “Create the Instance” of a connection to Salesforce, I got the following error message: “Failed to execute ‘json’ on ‘Response’: body stream is locked” and I was not able to proceed.

    Any idea of what is going on?

    Thanks,

    Marcelo.