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 the following:

  • 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 specification file must point to the sandbox host URL. If the host attribute is defined, the sandbox host URL for an API is displayed as ‘sandbox’ 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 configure 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 a productive environment, you can optionally choose to:

  • Apply these environment credentials/details to all the APIs within a package that are yet to be configured
  • Save the environment credentials/details for the current session only.
  • Save and persist the environment credentials/details for all the future sessions.

With the above 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 attribute in the API definition file.
  • You must have applied the defined security scheme defined using the security attribute in your API definition file.

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

Procedure for configuring a Productive API Environment

  • On the Homepage of SAP API Business Hub, choose an API package. You can also quickly search for an API package using the search functionality.
  • When the API package opens, choose the API for which you want to configure an API environment.

  • Choose the Configure Environments link.

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

  • In the Configure Environments dialog window, from the Starting Url dropdown list, select the required API endpoint that you want to configure. The list of API endpoints that appear is based on the endpoints defined under x-servers attribute in the API definition file.

  • In the Configure Environment dialog window, enter the environment details:
    • Display Name for Environment: Enter a human-readable name for the environment. For instance, if you have a productive environment for regression testing, you can enter the name of the environment 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-service, then 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.

Use this environment for this session only: If you select this checkbox, the user credentials are saved for the current session only.

Save this environment for future sessions: 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 this environment to all APIs in this package that are not yet configured: 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 environment details.

  • In the Starting Url dropdown list, you can now see the configured API environmentt .

  • Choose an API that you want to try out using the configured environment. In the API References section, choose the required resource and its HTTP method.

  • To test the API, choose Try out.

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

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 environment, 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