Skip to Content
Technical Articles

Building SAP UI with Salesforce data using REST Api’s

Overview:

SAP Cloud Platform is an integration and extension platform built for the Intelligent Enterprise that enables you to connect your landscape and create application extensions that focus on your business needs. This blog will help you learn and understand how can we access data from Salesforce systems using REST APIs and build our own custom applications.

What we will learn at the end of this blog –

  1. Accessing Salesforce trial account
  2. How to use Developer workbench
  3. Creating a connected application.
  4. Create Service key to access REST API’s
  5. Test the services in POSTMAN
  6. Create a UI5 application to display a list of Accounts / Service tickets.

Accessing Salesforce trial account –

Salesforce provides access to a trial account which is valid for 30 days. Please create an account by filling in the appropriate details. Please use the developer sign up link to create one.

How to use Developer workbench –

Salesforce Workbench is a highly adaptable and cloud-hosted toolkit provided to Salesforce Developers and Administrators to administer Salesforce organization using Force APIs. Using the Salesforce Workbench tool, they can easily perform Salesforce Object Query Language (SOQL) and Salesforce Object Search Language (SOSL), view their organization’s data, perform data loading and testing, deploy and troubleshoot their applications, and modify session settings.

Access Workbench with the following link – Workbench

Note – Workbench is free to use but is not an official salesforce.com product.

Create connected application – 

What is a connected application?

A connected app is a framework that enables an external application to integrate with Salesforce using APIs and standard protocols, such as SAML, OAuth, and OpenID Connect. Connected apps use these protocols to authenticate, authorize, and provide single sign-on (SSO) for external apps. The external apps that are integrated with Salesforce can run on the customer success platform, other platforms, devices, or SaaS subscriptions.

To create a connected application please follow the following steps –

  1. Login to your Salesforce account – Link
  2. You can browse different applications such as Account, Service, etc. Using this link will show you the list of service tickets created.
  3. Please navigate to the following path to create a connected application or alternatively you can use direct link.                                                                                                                     Settings-> Service setup – > User Interface- >App Manager -> New connected app

Search for User interface under which you need to select App manager to create a connected application. The following image shows the highlight of the same section in the red box.

Fill in the appropriate details for the connected application which you need to create. There are a few important fields that you need to fill correctly.

  1. Enable API (Enable OAuth Settings)
  2. Callback URL – https://login.salesforce.com/services/oauth2/token
  3. Selected OAuth scopes – You can select all or as per your requirement.
  4. Finally, Save the application.
  5. Please save the Consumer Key and consumer secret in a notepad which will be needing soon while accessing the API’s.
  6. After the application is successfully created we need to change OAuth policies so that all users can self-authorize while accessing the APIs.
  7. We will be using client credentials to generate an access token and with client credentials i.e username/password we all need to pass the Security token appended to the password. Follow the steps shown in the below images to access the security token.

Before we proceed further please make note of the following fields which we were able to create using the steps mentioned above –

  1. Consumer Key
  2. Consumer secret
  3. Security Token
  4. User Credentials

Test the services in POSTMAN

Download the full set of API collection from the Git link and import to your REST client (POSTMAN which I will be using for this test). After importing this you can set up your environment variable and fill in _endpoint and version. You can use the API version as per your choice which you can decide upon after going through the rest API developer guide mentioned in the reference links of this blog. I will be using version 20 for testing the api’s (Check developer workbench for different api’s versions available ). The following steps show you how to fetch access tokens which will be passing in while accessing the API’s.

Authentication – The Lightning Platform REST API supports OAuth 2.0 (an open protocol to allow secure API authorization). See Authorize Apps with OAuth in the Salesforce Help for more details.

 

Will take an example to fetch the list of accounts from Object Accounts in Salesforce.

Endpointhttps://ap16.salesforce.com/services/data/v20.0/sobjects/account/

Authorization Bearer {{TOKEN FROM the LAST STEP}}

After successful authentication, this will return a list of account present in the system, Feel free to play around with different objects (Accounts, Cases). To check different object available use the following API – https://ap16.salesforce.com/services/data/v20.0/sobjects/

Create a UI5 application to display a list of Accounts / Service tickets.

We will not cover all the steps on how to build a UI5 application rather I will show the destination configuration on SAP Cloud Platform which you need to create. Please check the below image and create one with your credentials. (Make sure you suffix security token with password as you did while testing in POSTMAN).

Log in to your SAP Cloud Platform account and select the respective sub-account where you want to build the application.

Using the destination created you will be able to fetch the data ad build your custom UI5 application. Following are the 2 examples where we were able to list accounts and cases from the Salesforce systems.

 

So we have successfully fetched the data from Salesforce systems and able to build the custom web applications using SAP UI5. I hope you found it interesting and would like to give a try 🙂

Please do drop in your thoughts in the comments section. Thank you !!

 

Reference Links –

  1. https://help.salesforce.com/articleView?id=connected_app_overview.htm&type=5
  2. REST API developer guide – https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/quickstart_oauth.htm
  3. https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_basic_info.htm
  4. https://help.salesforce.com/articleView?id=remoteaccess_authenticate.htm&language=en_US
3 Comments
You must be Logged on to comment or reply to a post.
  • This is a great read Jay, I’d like to know if these steps change using Open Connectors, what the differences are when using Open Connectors to create the connectivity.  Look forward to seeing more from you!

    • Nic, thank you for your feedback.  Using an open connector is very simple we don’t need to have all these steps done. This blog will help to understand what happens underneath and if you want to consume directly will help you. I will try to put the steps to achieve the same using open connector and how OC make life easy.