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://my346234.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/$metadata

Use the basic authentication credentials below to configure the integration:

FieldValue
UserDemouser
PasswordWelcome1
Note

Try to enter the user and password correctly or the system might lock you out. In case of lock-out, please contact: sandra.hathaway@sap.com

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://my1234567890.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/$metadata

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://my346234.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/$metadata

  3. Choose Basic Authentication and use the credentials Demouser / Welcome1. (Is different in your landscape)

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

  5. 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.

  6. Click on the newly created OData integration.

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

  8. To test the results, enter Demouser as User and Welcome1 as Password.

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

  10. 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".

Save progress to your learning plan by logging in or creating an account