Sunday, October 4, 2020

SAP API Management - Quota Policy - Unique Counters

 Scenario: You want to limit API calls based on time interval for each client application

Steps:

1. Add an instance of Quota in Preflow for incoming request.


2. Modify the code as per requirement.

Code (Allow 2 calls/min for each client application)

<Quota async="false" continueOnError="false" enabled="true" xmlns="http://www.sap.com/apimgmt">

    <Identifier ref="request.queryparam.app"></Identifier>

  <Allow count="2"/>

  <Interval>1</Interval>

<Distributed>true</Distributed>

<Synchronous>true</Synchronous>

  <TimeUnit>minute</TimeUnit>

</Quota>

3. Test the API 

Send client application name as query parameter as below.

https://<host>:<port>/<path>?app='app1'

In this case, during 3rd call within a minute for the same client application, the below response is received.





No comments:

Post a Comment