Skip to Content

Connect Your SAP Build Application to a Public API

Connect your application to a public API and then test that it's pulling the right information.
You will learn
  • How to add and configure data resources
  • How to test data resources
thecodesterDaniel WroblewskiApril 29, 2025
Created by
thecodester
November 5, 2024
Contributors
thecodester

In the previous tutorial, you configured your application to open a device camera once the scan button is tapped. This currently reads the barcode and displays the barcode number.

To improve on this, you will configure a data source that has food information related to that barcode. For this tutorial, you will use the Open Food Facts public API.

  • Step 1
    1. Open your app to the Integrations tab.

      Add data source
    2. Under SAP Build Apps classic data entities, click Create Data Entity.

      Select Universal REST API integration.

      Rest API direct integration
    3. Configure the resource with the following details:

      Field Value
      Data entity name OpenFoodFacts
      Base API URL https://world.openfoodfacts.net/api/v0
      Data entity description Data from Open Food Facts API
      Enter data resource information
    4. Scroll down to the Additional Inputs section, and click Add New to add a placeholder for a parameter in the URL.

      Additional inputs

      The API enables us to send a barcode as part of the URL, and then returns information about the food with that barcode.

      In the dialog, add a field called barcode of type text.

      IMPORTANT: Make sure you do not add an extra space to the end of barcode.

      Click Add.

      Additional inputs

      If you scroll down you will see the additional input.

      Additional inputs result
  • Step 2

    You now need to configure which information is taken from the Open Food Facts API. This can be achieved using a Retrieve request.

    1. Click on Retrieve and enable the request by turning on the toggle switch.

      Enable retrieve
    2. In the Relative path and query field enter, click on the X.

      Start binding for path

      Select Formula.

      Formula

      Click Create formula.

      Create formula

      Enter the following formula:

      JavaScript
      Copy
      "/product/" + query.additionalInputs.barcode + "?fields=product_name,nutriments,image_front_url"
      

      The API contains 100s of fields. We added a filter to make it easier to work with in the project.

      Click Save twice.

  • Step 3

    You will now test to see if the resource is configured properly.

    1. Go to the Test tab.

      Test configuration
    2. In the barcode additional inputs, enter the following:

      JavaScript
      Copy
      6416453061361
      

      Click Run Test.

      Run test
    3. Scroll down a little to see the response.

      In this response, you can see just the information we need: product name, nutritional information, and an image.

      View the results

    In the test response, search for the field "product_name", and enter its value below.

  • Step 4

    After a successful test you should now set the data schema. This stores the data structure from the URL, enabling the application to easily identify the types of information it is fetching.

    1. In the same window where you did the test, scroll back up and click Autodetect Schema from Response.

      Set schema

      If you click back to the Base tab, you will see the response schema now set.

      Set schema
    2. Click Save Data Entity (bottom right).

    3. Click Save (upper right).

    When creating a universal REST API integration (data resource), which of the following types of calls can you make?

Back to top