Creating REST Resources

Objectives

After completing this lesson, you will be able to:

  • Create a data resource to a REST API.
  • Access the REST data resource from your app.

REST Resource

A REST resource is a connection to a data source that adheres to the REST protocol. This is a more generalized type of data service than OData. REST services are not required to provide metadata about the service. Therefore, when setting them up in SAP Build Apps, you might need to provide a little more configuration information about them.

There are two main things that you must define:

  • Schema of the data that provides a structured view of information
  • Types of HTTP requests that can be performed on the data resource

There are thousands of REST services, some free and some for pay, to get all types of information, such as:

  • Weather reports
  • Sports information
  • Jokes
  • Geological information
  • Government information and many more

Create a REST Resource

Business Scenario

Play the video to learn how to create a data resource based on a REST service and access the data.

Access Data from the REST Resource

Business Scenario

This procedure describes the required steps to access the data.

Steps

  1. Access the data.

    1. Choose the Data tab again to go back to the UI canvas.

      There should be a title and text component.

    2. Choose the title component, and in the Properties pane, change the Content to Teams.

    3. Choose Variables.

      Now, we will create a data variable that will store the data from the back-end and will contain logic for retrieving it.

    4. Choose Data Variables, and then Add Data Variable.

    5. Choose MLBTeams as the data resource on which to base the data variable.

    6. Choose View to go back to the UI canvas.

    7. Choose the text component and we will configure it to show the customer names. In the Properties pane, choose the icon under Repeat with, then select Data and Variables, then Data Variable. Select MLBTeams1 and choose Save.

      The text component will now display 4 times to indicate it is repeated (the 4 times does not indicate the amount of data … it will always be 4 times).

    8. In the Properties pane, choose ABC under the Content field, and select Data item in repeat. Select current, and then select Name.

    9. Choose Save.

  2. Perform a test.

    1. Run the app, and you will see a list of teams retrieved from the back-end.

Log in to track your progress & complete quizzes