Skip to Content

Overview

Consume and test the APIs available on SAP API Business Hub in a productive environment.  A productive environment, for example could be a combination of a web service on an active SAP Cloud Platform account, the real data available for that web service, and the APIs to be tested against the real data.

This testing experience is achieved using API endpoints, which are pre-defined for each API in its API specification file. These API endpoints are configurable in such way that they can point to a service on the tenant account thus allowing productive usage of APIs for building real applications.

In-house capability  

In SAP API Business Hub, to test APIs, a sandbox environment (combination of sandbox host URL and API Key) is provisioned as a default API endpoint for every logged in user. However, sandbox only allows you to test APIs against test data.

To enable sandbox testing experience, the host attribute of the API in API definition file must point to the sandbox host URL. If the host attribute is defined, the sandbox host URL for an API is displayed in SAP API Business Hub as shown below:

If the sandbox host URL is not defined for the API, then API sandbox is not available for test experience.

Productive Environment

In addition to the sandbox test environment, SAP API Business Hub provides a capability that enables users to try out APIs in a productive environment, via configurable API endpoints.  That is, it allows users to test APIs against the live data available in their productive/tenant account.

For example, consider an API consumer has an active BPM workflow web service running on a productive SAP Cloud Platform account.  The API consumer intends to consume APIs available on SAP API Business Hub and test them against the data available in BPM workflow web service. In such a case, the API Business Hub allows the API consumer to configure an API endpoint pointing to the BPM workflow service on SAP Cloud platform account

The API endpoint to be configured, for example can include application name, account names, host, and the service against which you want to try out the API.

A sample configurable API Endpoint is shown below:

During the configuration of an API endpoint, you can optionally choose to:

  • Save and persist your user credentials
  • Apply credentials to all the APIs available in an API package.

With the above two options, you can experience a seamless try out experience.

To enable API testing in a productive environment, the following prerequisites must be met:

  • You must be logged on to SAP API Business Hub
  • The API that you want to try out must contain at least one configurable API endpoint defined under x-servers attribute in the API definition file.
  • In case the API is protected via security schemes, then the API definition file must also contain a security definition (authorization type) defined under securityDefinitions

A sample API definition with x-servers and security definitions information is shown below:

Procedure for configuring an API Endpoint

  • On the Discover page in SAP API Business Hub, choose an API package.
  • In the ARTIFACTS tab, choose the API for which you want to configure an API endpoint.

The list of APIs belonging to the artifact is displayed in the RESOURCE tab.

  • Choose the Configure link.

The Configure link will be disabled if the API does not contain any configurable API endpoint.

  • In the Configure URL dialog window, select the required API endpoint from the list, which you want to configure. The list of API endpoints appears based on the information defined under x-servers attribute in the API definition file.

  • In the Configure API Endpoint dialog window, enter the API Endpoint details:
    • Endpoint Alias: Enter a human-readable name for the endpoint. For instance, if you have a productive environment for regression testing, you can enter the name of the endpoint as ‘Regression’.Depending upon how API endpoints are defined in the API definition file, relevant fields are shown for configuration.For example, in the API definition file, if an API endpoint is defined as:https://bpmworkflowruntime{provideraccountname}-{consumeraccountname}.hana.ondemand.com/workflow-servicethen the following fields appear as configurable fields.

      provideraccountname: The name of the provider tenant account.

consumeraccountname: The name of the consumer tenant account.

 

In case if the API is protected via a security scheme, for example, say if basicAuth is defined as authorization type for the API, then the relevant basic authorization fields (in this example, Username and Password) will also be shown as configurable fields.

Username: The username of the tenant account

Password: The password for the tenant account

Note that if other security schemes (authorization types) are defined for the API, you may see additional fields such as OAuth2 or apiKey available for configuration. Enter the required details against these fields and continue.

Save my credentials: If you select this checkbox, the user credentials are saved and persisted. If it is not selected, the user credentials are saved until you log out/until the end of current session.

Apply credentials to all APIs which are not configured in this package: If you select this checkbox, the user credentials that has been entered for the selected API are applied to all the non-configured APIs in the API package.

  • Choose OK to save the API endpoint details.

  • In the API Endpoint dropdown list, you can now see the configured API endpoint with the Endpoint Alias.

  • Choose an API that you want to try out using the configured endpoint. In the RESOURCE tab, choose the required resource and its HTTP method.

  • To test the API, scroll to the end of the documentation, and choose Try it out!.

The Request URL will show a response with the configured endpoint.

You might have to enter a few mandatory parameters, depending on which API you are using.

Summary:

In above steps, we experienced how easily we could configure the API endpoints, point it to our own instance of Service and experience the API. This API can further be consumed to build applications.

 

 

 

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply