[SAP CPI] – HOW TO EXPOSE INTEGRATION FLOW ENDPOINT AS A API

Hi guys, in this article I want shared step by step How to expose Integration Flow Endpoint as API. Normally, after we develop Integration Flow is done, we get the end point to test on POSTMAN. This way is no wrong, but in cases we have many API related together, Ex: we have 10 API related to SALES, ang we want to group them together. In this case, we use API Management to expose Integration Flow Endpoint. Here we go.

Kindly go to here to know how to use token with https sender adapter

Note – Environment : Cloud Foundry – CF

Step 1 : Create Integration Flow

In this step, we create two integration flow as

  • Get All Product
  • Get Product with Product ID

Integration flow will call ODATA at : https://refapp-espm-ui-cf.cfapps.eu10.hana.ondemand.com/espm-cloud-web/espm.svc

For step by step How to create Integration Flow with External Call OData, kindly ref in another article. In this article, for simple I create integration and put screenshot here.

Important : No need check option in HTTP sender adapter : CSRF-token Protected. If check it then we will receiver 403 forbidden when configure API management with method POST.

  • Get All Products (/http/products/all)

Get by Product ID (/http/products/getbyId)

To this time, we have two integration endpoint

Get all productshttps://<host-tenant>/http/products/all
Get products with Idhttps://<host-tenant>/http/products/id

Step 2 : Define API

In this steps, we will expose two integration flow as API for customer. Base on endpoint we will expose one API including 2 method GET, POST

  • Go to sub account
  • Go to Instances and Services
  • Go to Integration Suite
  • Go to Design, develop and manage API
  • Go to API
(1)URL
(2)For endpoint of integration flow is https://<host>/http/products/all then we just get https://<host>/http/products
(3)/products ( or anything)

IMPORTANT : resource name must be the same with resource in integration flow endpoint

  • Create and deploy it.
  • This time, we receive status 401 because no access token configure here
  • Next, we config payload for POST API. Click edit in API Design and change text map with body in POSTMAN

After done, we have

Step 3 : Create service key and get information for token

  • Go to Instances and Services
  • Click on service :process integration runtime. If do not see it, kindly install
  • Get information token

Step 4 : Assign policy template

After define API, we use endpoint API test on POSTMAN, we need get access token, because at step configure integration flow, we use https sender with CSRF-token, so current we call API we will receive status code : 401- Unauthorized or 403 – Forbidden

For get access token, we have two way :

  • Get access token from POSTMAN with service key. Ref here to know step by step
  • Configure access token in API management by apply policies template. In this step, we will do it.

Step 4.1 : Copy package from Business Hub

Package name :
Connect to SAP Business Technology Platform Services

  • Go to tab artifacts
  • Copy it

Step 4.2 Apply policies template to API

  • Go to API which apply this policies. In this article, go to API products and getByProductId
  • Edit, click apply template
  • Choose template
  • Configure access token in TargetEndPoint => PreFlow
  • GetCredential

(1) : Client ID from Service Key

(2) : Client Secret from Service Key

  • Get OAuth Token

(1) : Token URL from service key. Remember add ?grant_type=client_crendentials

  • Update – Save – Deploy

Configure for API GetByProductID the same.

Step 5 : Test from POSTMAN

As you see, We no need authentication from client (POSTMAN), because access token configured in API management.

Test from API Management by Swagger

Test POST method in API management swagger

Summary

In this article, I shared step by step How to expose integration flow endpoint to API management. I also shared how to get template policies to config access token flow by Connect to SAP Business Technology Platform Services. Thanks for your reading and any question, kindly leave your comment on below this.

Thanks.

Joseph.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.