SAP Cloud Platform API Management : Metadata cache for OData APIs
Metadata Cache for OData APIs policy template in SAP API Business Hub allows a full caching of the metadata which significantly increases the performance of OData APIs managed by SAP Cloud Platform API Management. A policy template is a collection of policies or behaviors that can be reused across API Proxies, this policy template improves the performance of OData APIs by caching the $metadata response and reducing the load on the target system by returning the cached metadata response from SAP Cloud Platform API Management.
In this blog, the usage of Metadata Cache for OData APIs policy template for OData APIs from various target system like SAP S/4HANA Cloud, SAP SuccessFactors, SAP Gateway, SAP Hybris Cloud for Customer or Third party is covered in detailed.
- SAP Cloud Platform API Management ( ref link for trial access)
Discover and Copy Metadata Cache for OData APIs policy template
From SAP Cloud Platform API Management, all the APIs and policy templates available in SAP API Business Hub can be discovered via the Discover tab.
- Logon to your SAP Cloud Platform, API Management account (say https://account.hanatrial.ondemand.com/cockpit).
- Navigate to the Services tab, search for API Management service tile and click to open SAP API Management service.
- Click on the link Access API Portal to open API Portal.
- Navigate to the Discover from the hamburger icon
- SAP API Business Hub is integrated into SAP Cloud Platform API Management and therefore all the APIs and Policy templates available in SAP API Business Hub can be easily discovered and consumed in SAP Cloud Platform API Management.
- Navigate to the All tab, search and select Metadata Cache for OData APIs.
- Navigate to the Artifacts tab and select cacheMetadata policy template.
- Click on Copy to copy the metadata cache policy template into SAP Cloud Platform API Management tenant
- Copied metadata cache policy templates would be available under POLICY TEMPLATES tab of Develop view.
Apply Metadata Cache for OData APIs policy template to SAP S/4HANA Cloud OData APIs
In the blog series Discover, Consume and Manage SAP S/4HANA Cloud APIs the detailed steps to access the Read Planned Orders SAP S/4HANA OData API and the management of the Read Planned orders API via SAP Cloud Platform API Management is covered. In this section steps to apply metadata cache to the API_PLANNED_ORDERS API Proxy is covered in details.
- Click on APIs tab and select API_PLANNED_ORDERS SAP S/4HANA Cloud OData API.
- Click on Policies to navigate to the Policy designer view.
- Click on Edit to switch to the editable mode.
- Select Apply from the Policy Template.
- Select the newly copied cacheMetadata template from Apply Template dialog.
- Click on Update to save changes in the policy designer.
- Click on Save to apply the changes to the API_PLANNED_ORDERS.
With this caching of the OData metadata has been completed.
Finally testing the flow
- Select the RESOURCES tab and click on GET operation view all planned orders from your SAP S/4HANA Cloud tenant.
- This would open up the Test Console, click on the Authentication option and select Basic Authentication. Enter the communication users credentials ( say COM_104 as created in section Creation of Communication User of Part 3 of Discover, Consume and Manage SAP S/4HANA Cloud API blog series) and click OK.
- In the URL, provide the $metadata URL by appending $metadata after API_PLANNED_ORDERS.
- Click on Send to test the API Proxy for Read Planned Orders
- The first response time would be little higher.
- The subsequent time would be much faster.
The Metadata cache policy template can be applied to any OData API to improve the performance of Odata APIs by caching $metadata response and reducing road trips to the target system for metadata calls.
For more blogs on SAP Cloud Platform API Management visit us at SAP Community