Creating an API Proxy

Objective

After completing this lesson, you will be able to create an API based on the API provider

Creation of APIs Based on the API Provider

In this lesson, the following topics are discussed:

  • What are the possibilities to create an API?
  • Create an API using the Create button.
  • Create an API using menu links.

What are the Possibilities to Create an API?

The API, which will be created, is important for further implementations. It acts as a proxy of the actual resource API. The previous name was API Proxy. This name often appears in older documents.

The following options are available:

Create an API using the Create button with the following options:
  • API provider (No. 1 at concept diagram)
  • URL (No. 2 at concept diagram)
  • API proxy
Create an API using menu links with the following options
  • Create in API Designer (No. 3 at concept diagram)
  • Import an external API
The diagram shows the options using the Create button.
The diagram shows the options by using menu links.

Create an API Using the Create Button

This is probably the most common case. With this option, you can create an API with an API provider, a provided URL, or an existing API.

Procedure

  • Start with DesignAPIs to open the Develop screen.

  • Start the wizard by choosing the Create button. A new window opens.Screenshot of the Configure page with API Proxies, APIs, and Create buttons.

Use the API Provider option.

Screenshot of the options using menu links with Internet and API Provider boxes highlighted.

Select the API Provider radio button and open the selected box. All API providers display. Choose one, for example, SAPGatewayDemoSystemES5_Provider.

Screenshot of the API Provider selection.

When the API Provider is chosen, a new list box with the name Discover is available. Some data, such as the host and the type of API, have already been entered.

When the list box is chosen, all available services listed within the catalog service are displayed.

What exactly is displayed here depends on the type of API Provider. In the case of Open Connectors, for example, all instances are displayed. For the type Cloud Integration, the available integration flows are displayed.

The following figure shows a list of available services, which are usable from the SAP backend system. The API provider gets defined by choosing one service from the provided catalog services.

Screenshot of a list of available services in an SAP backend.

You can choose exactly one of the offered services. After that, further data is added to the mask.

Screenshot of API Provider selection.

When you finish creating this API (proxy), it has to be deployed so that it can be used. After that, the API (proxy) is ready for testing. The service type is automatically defined. In this case, it is OData.

Use the URL option to create an API

In case you do not use an API provider, you can directly specify the URL of your source.

To create an API, choose URL from menu links.

In this case, you must enter the data manually (marked). The Service Type can only be REST or SOAP.

Screenshot of the different service types.

After saving and deploying the API, it can also be tested.

Use the API Proxy option to create an API

In this case, you can copy an existing API.

Screenshot of existing APIs.

In this case, you must enter the data manually (marked). The Service Type can only be REST or SOAP, even if the spied API is from type OData.

Create an API Using Menu Links

Screenshot of API Designer in menu links. Information about using the Create in API Designer option is provided below.

Use the Create in API Designer Option

Start creating an API by choosing the menu link, Create in API Designer.

Choose Create in API Designer.

Switch to the openAPI editor. You can manually create your API there through the openAPI language in YAML. In this case, all entries must be created manually. The server URL is automatically adjusted after saving. The Service Type can only be REST.

Before Saving

Screenshot of the URL before saving.

After Saving

Note

Be aware that the shown URL is a sample and will not work.

Screenshot of the URL after saving.

Import an External API

Screenshot of external APIs in menu links.

Start the creation of an API by choosing the menu link, Import API.

Choose Import API.

The Service Type corresponds to the imported API.

Resource

Help Portal: Create an API Proxy

Summary

There are several ways to create an API. APIs can be created:

  • By using the Create button.
  • Based on an existing API provider.
  • Directly through an provided URL.

Finally, you can also define it with an openAPI specification via the Create button in API Designer.

Create an API Based on a Predefined API Provider

Business Scenario

The objective is to establish a connection between the API provider, indicated in green, to a new API that we are developing within the API Management. The subsequent connection and associated artifacts that emerge from this process are marked in red within the component diagram.

API Provider Diagram

Task flow

In this exercise, you will perform the following tasks:

  1. Create an API proxy.
  2. Test the API proxy.

Prerequisites

You have successfully completed the previous exercises.

Outcome after this exercise

You have a working API based on the API provider from the ES5 system. This allows APIs to be called from the ES5 system.

What do you learn within this exercise

After this exercise, you can create and configure an API proxy based on an API provider. This allows you to call the GWSAMPLE_BASIC OData interface on the ES5 backend.

Task 1: Create an API Proxy

Steps

  1. Create an API proxy based on the naming convention GWSAMPLE_BASIC_date_subaccountnumber.

    1. Log in to your SAP Integration Suite.

    2. Navigate to Configure, APIs, API Proxies and choose the Create button.

      API Proxy Setup
    3. In the API Provider field, choose your previously created API provider named APIGatewayDemoSystemES5_Provider.

      API Proxy Creation
    4. Now that we are fetching the catalog data from the ES5 system, we must select a specific API. Select the Discover button, which is available after choosing the API provider.

    5. After selecting the Discover button, a new pop-up window appears to display the available Business APIs on the ES5 system.

      Discover Service
    6. Search for GWSAMPLE_BASIC, choose the pop-up button at the start of the row, and then choose the OK button.

      Service
    7. You return to the initial pop-up window, and most of the fields will be prefilled with data. Please note that the Host Alias depends on your SAP BTP trial account. In some screenshots, x00-cld900.apimanagement.eu12.han.ondemand.comis used. However, this does not affect the functionality.

      Api Proxy Generation Window
  2. Configure your predefined API proxy.

    1. Add your date and subaccount number as a postfix at the end of the Name and Title fields. We are using the API Proxy name: GWSAMPLE_BASIC_23042024_pa. Feel free to use your own name.

      wizar api proxy
    2. Enter v1 into the Version field. The v1 is immediately appended as a prefix in the Name field and as a path postfix in the API Base Path field.

      versioning api proxy
    3. Add the v1 postfix manually at the end of the Title field.

      create api proxy
    4. Afterwards, choose the Create button. Subsequently, the wizard pop-ups close, and you are redirected back to the Create API page.

      API Proxy Overview
    5. Choose the Deploy button to activate the API proxy. If everything has been correctly set and the API proxy has been successfully deployed, the API proxy URL can now access the OData service GWSAMPLE_BASIC at ES5, as displayed.

      API Proxy URL
    6. Navigate back to the Configure menu, either by using the breadcrumb navigation at the top left or via the main menu on the left, by selecting ConfigureAPIs.

Task 2: Test the API Proxy

Steps

  1. Test with the proxy resource.

    1. Navigate to the detail page, choose your API proxy.

      api proxy overview
    2. Open the detail page of your API proxy by clicking on the row containing your API proxy. Then, switch to the Resources tab.

      Resources
    3. Search and find the entry for ProductSet.

      api proxy ressources
    4. Choose the ProductSet resource to unfold the user interface, then choose the GET/ProductSet method area.

      try out resources
    5. Choose the Try it out button.

    6. Scroll further down until you see the blue Execute bar.

      execute the api proxy resources
    7. Choose the Execute bar to send your request.

      http response code
    8. The request fails with an HTTP code 401 - Unauthorized, as we have not enabled authorization for the call. We do this in a later exercise by involving policies. The authorization set during the creation of the API provider was solely for calling the Catalog Service.

  2. Test your API proxy with the Test functionality.

    We have observed that the API proxy URL results in an authorization error when the resource GET /ProductSet is invoked. This error is due to missing authentication involving a user and password connected to the original interface.

    Currently, the SwaggerUI does not allow us to implement basic authentication as there are no fields designed for a user and password. Though one could modify the OpenAPI Specification to include these.

    Regardless, a standard function does exist that allows us to conduct testing with Basic Authentication.

    1. Navigate with the left side menu to TestAPIs.

      test apis
    2. Choose your API proxy from the left side, for example, GWSAMPLE_BASIC_date_subaccountnumber.

    3. In the address navigation menu, add /ProductSet to the end of the path. The GET method is automatically selected.

      API Test Console
    4. Choose the Authentication: None-link above the address bar. Choose Basic Authentication .

      authentication
    5. Enter the user and password for the ES5 system. Afterwards, choose the OK button.

      Test Console API
    6. Choose the Send button on the bottom right.

      API test Console
    7. If you get an HTTP status code 200, everything works as expected.

      If the call was successful, as in the screenshot shown, all the data records hosted on the database are displayed as a feed in the response. If you don't get an HTTP status code 200, check your authentication credentials.

Log in to track your progress & complete quizzes