Expose Integration Flow Endpoint as API and Test the Flow
- How to define and expose an integration flow endpoint as an API
- How to assign a policy to your API
- How to call your API and execute the integration flow using the API portal
- You have provisioned your SAP Integration Suite tenant and activated Design, Develop and Operate Integration Scenarios and Design, Develop and Manage APIs. For more information, see Set Up Integration Suite Trial.
- You have created and deployed an integration flow that reads product details using an OData connection. For more information, see Design and Deploy Your First Integration Flow.
In this tutorial, you will define the endpoint of the integration flow developed in the last tutorial as an application programming interface (API).
In addition, you will assign a policy template to the API to define how the API is called. A policy defines, for example, how an API can be called. In this tutorial, you assign a policy that defines an authentication of the API according to OAuth 2.0 client credentials grant. It is a secure way to control access to an API.
After you have performed these steps, finally, you will call the API to fetch the product details.
You have successfully set up your Integration Suite trial, designed a simple integration flow that reads data from a remote component, and defined the integration flow endpoint as an API. Finally, you have successfully called the API to get product details as a response from the remote component.
This scenario showed you how to use Integration Suite, and in particular, its Cloud Integration and API Management capabilities seamlessly integrated, end-to-end.
- Step 1
In this step, you copy the endpoint address of the integration flow.
Go to the Cloud Integration Web UI and open your integration flow.
In the Deployment Status tab of the property sheet, choose the URL.
In the Endpoints tab, choose Copy icon.
- Step 2
In this step, you define and expose an integration flow endpoint as an application programming interface
Go to your SAP BTP trial subaccount. Select Instances and Subscriptions. In the Subscriptions, section, find Integration Suite and select Go to Application.
On the Integration Suite welcome page, choose Design, Develop and Manage APIs.
On the home page, under Quick Actions, choose API.
On the Create API dialog, next to Select: choose URL and specify the following parameters:
IMPORTANT : Paste only the endpoint URL till
/http/productsOtherwise, the scenario will not run appropriately.
Parameter Settings URL Paste the integration flow endpoint address you have copied in step 1. It ends with
/http/products/details. Note: paste only the endpoint URL till
Product Details API
API Base Path
On the landing page, choose Resources tab and then Add.
In field Tag enter
Product Details, and in the field Path Prefix enter
Under Operations, delete all tabs except the POST tab and choose OK.
The API Resource is displayed.
Choose Deploy to create and activate the API Proxy for your integration flow.
Choose the POST operation to display more details on the API. A default API definition in Open API specification format is also generated.
To update the generated API definition in Open API format, choose Edit > Edit in API Designer.
The API designer is opened.
In the editable section on the right part of the screen, make the following changes.
Change Payload to
productIdentifierand add a row as shown in the following screenshot.
TIP: Instead of copying the example, type it manually.
RequestProductDetailsand then the Resources tab.
Choose the POST request. You notice the API changes, in particular, the request body contains now one element with a product identifier.
When you choose Try Out and then Execute, since no authentication details have been configured, you get an error message with error code 401 (not authorized).
With this step, you have successfully created an API Proxy for your integration flow and generated an API documentation for your REST API in
- Step 3
In this step, you’ll copy the client ID, client secret, and token URL from the service key that you automatically generated using a booster in Set Up Integration Suite Trial.
Navigate to your service instance page which you earlier opened at the end of Set Up Integration Suite Trial. You can access this from your subaccount. Choose Services > Instances and Subscriptions.
Under the Instances section, look out for the service instance that was created by the booster. Usually the default name that the booster provides is default-it-rt-integration-flow. Choose the key under the Credentials column to open the service key.
Copy the values of
tokenurlparameters. These are the credentials that you use to make a request to your integration flow.
- Step 4
In this step, you assign a policy template to your API to specify authentication details for the API call. In particular, you use a policy template that defines that the caller of the API authenticates itself using OAuth 2.0 client credentials grant.
This grant type works in the following way: In a first call, the API client provides the values of
clientsecret(from the service key generated in Step 1) to a token service (the URL of the token service is also contained in the service key definition). The token service provides an access token to the API client. In a subsequent call, the API client calls the integration flow endpoint providing the access token. If the access token is valid, the API client is authorized to call the integration flow.
In the navigation area of API Portal, choose View content packages.
Search for the package Connect to SAP Business Technology Platform Services. Choose the package.
Navigate to Artifacts tab.
Under Actions, choose Copy.
After the success message is displayed, navigate to the Develop section.
Choose your API proxy.
The Policy Editor opens.
Choose Policy Template –> Apply.
Select the template
Cloud_Platform_Connectivityand choose Apply.
Open the node Target Endpoint.
In the editor, the OAuth workflow defined by the policy is visualized as a graphical model.
Now, you need the values copied from the service key:
In the graphical model of the Policy Editor, choose the
Paste the value of
clientsecretas shown in the following image.
In the Policy Editor, choose the
Paste the value of
tokenurlas shown in the following screenshot.
Note: Make sure that you append
?grant_type=client_credentialsto the token URL that you pasted.
Select Click to Deploy.
Confirm the deployment.
You have assigned a policy template now.
Which of the following values are mandatory to authorize the API client and to call an integration flow as an HTTP endpoint?
- Step 5
In this step you try out the API to get product details as a response from the remote component.
Go to the Resources tab.
Choose Try Out.
As result, you see the response from the
WebShopwith the product details for the given product identifier.