Connecting the SAP Sales Cloud OData API with SAP Build Apps

Objectives
After completing this lesson, you will be able to:

After completing this lesson, you will be able to:

  • Connect data with an API URL

Introduction: Connection of an SAP Sales Cloud OData API with SAP Build Apps

Next, we are going to set up the connection to the open data application programming interface (Odata API) of SAP Sales Cloud. This can be done by configuring an OData type data resource in SAP Build Apps. An API allows us to fetch data from SAP Sales Cloud to use in our extension app. OData is an open API standard used by many SAP APIs. JSON is a popular data format used by APIs.

An API allows us to fetch data from SAP Sales Cloud to use in our extension app:

  • OData is an open API standard used by many SAP APIs.
  • JSON is a popular data format used by APIs.

Connect an SAP Sales Cloud OData API With SAP Build Apps

Connecting Data with an API URL

An API URL is like any web address, except that it is used to communicate data between two systems.

This is the mock API URL for the OData service: https://btp150-proxy.c-2828549.kyma.ondemand.com/sap/c4c/odata/v1/c4codataapi/$metadata

Verifying the API URL is Working

To verify that the OData API URL works you can drop the URL into your browser to visit the URL and see the XML metadata of the OData service.

Note

The URL provided allows anyone to complete this training exercise even if they don't have access to an SAP Sales Cloud instance. If you do have access to an SAP Sales Cloud instance with the OData API, you can create the app using it. In this case, you should reformat the URL to this: https://btp150-proxy.c-2828549.kyma.ondemand.com/sap/c4c/odata/v1/c4codataapi/$metadata.

Please also note, that you are accessing the SAP Sales Cloud instance through a proxy, that attaches credentials to your requests.

If you use your own instance, you’ll need to create some appointments in your system to be able to display and filter them in the extensions app. Depending on your setup, you should also have your login credentials for the SAP Sales Cloud instance, as you’ll need to enter them for the Basic Authentication configuration when configuring the integration in SAP Build Apps.

Configuring the OData Integration

To start configuring the OData integration we have to connect the OData API with SAP Build Apps. The data that will be returned is in the JSON data format. SAP Build Apps will store and use this data structure, making it easy to work with the data resource as we develop our app.

Creating Connections to an OData API From the App

Creating a Data Variable

To use the configured data resource in our app, we need to create a new data variable. Data variables in SAP Build Apps are always created from data resources and they allow the UI components to interact with the data.

To Create Connections to an OData API from an App

Steps

  1. Click on the Data tab at the top.

  2. Paste in this URL: https://btp150-proxy.c-2828549.kyma.ondemand.com/sap/c4c/odata/v1/c4codataapi/$metadata

  3. Click on Verify URL and switch on the AppointmentCollectionresource and save the data resource.

  4. Click on the created data resource, scroll down and switch on all the related resources by clicking on the switches, and then press SAVE DATA RESOURCE.

  5. Click on the newly created OData integration.

  6. Click on the list subcategory and switch to the Test tab.

  7. Scroll down and click on the Run Test button.

  8. Exit the Data tab by clicking it again to get back to the canvas.

To Create a Data Variable

Steps

  1. Switch to the variables’ view. Click on the DATA VARIABLES tab on the left side, and then click on ADD DATA VARIABLE. Select the Data resource we created beforehand.

  2. Filter to show only the appointments in the category "Marketing".

  3. Click on Object with properties. This allows us to create a filtering condition.

  4. Create a condition to show only results from the CategoryText field with a value equal to Marketing. This works because in SAP Sales Cloud we define different categories for appointments and in our sample data, we have 3 appointments with the category "Marketing".

  5. Click on the "ADD CONDITION button; a box pops up in which we filter by the CategoryText property and leave the Condition type as equal. The condition type shows under which condition the appointments are being filtered.

  6. Write in the Component valueMarketing, since we want to get every appointment with in the category Marketing displayed.

  7. Click on Save. We have set up our data variable. Let’s now go back to the canvas view by switching the toggle from "Variables" back to "View".

Log in to track your progress & complete quizzes