Hi
I am trying to use custom attributes from API Product in Quota Policy.
But it's giving below error
{ "fault": { "faultstring": "Failed to resolve quota interval reference verifyapikey.Verify-API-Key.apiproduct.quotaInterval in quota policy {1}", "detail": { "errorcode": "policies.ratelimit.FailedToResolveQuotaIntervalReference" } } }
Quota Policy looks like
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Quota async="false" continueOnError="false" enabled="true" name="Quota"> <DisplayName>Quota</DisplayName> <FaultRules/> <Properties/> <!-- <Interval>1</Interval> <TimeUnit>minute</TimeUnit> --> <Interval ref="verifyapikey.Verify-API-Key.apiproduct.quotaInterval"/> <TimeUnit ref="verifyapikey.Verify-API-Key.apiproduct.quotaTimeUnit"/> <Allow countRef="quota_limit_one"/> <Distributed>true</Distributed> <Synchronous>true</Synchronous> <PreciseAtSecondsLevel>false</PreciseAtSecondsLevel> <Identifier ref="request.queryparam.tenantId"/> </Quota>
quotaInterval and quotatimeUnit are custom attributes in API Product.
Please let me know what is missing here.
Thanks
hi @GAURAV, i tried your code, only one change and it works fine, ref for Interval and TimeUnit for the Verify-API-Key should be the name of your verify api key, for e.g. in my case it is Verify-API-Key-1
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <VerifyAPIKey async="false" continueOnError="false" enabled="true" name="Verify-API-Key-1"> <DisplayName>Verify API Key-1</DisplayName> <Properties/> <APIKey ref="request.header.apikey"/> </VerifyAPIKey>
so if you change your code with this;
... <Interval ref="verifyapikey.Verify-API-Key-1.apiproduct.quotaInterval"/> <TimeUnit ref="verifyapikey.Verify-API-Key-1.apiproduct.quotaTimeUnit"/> ...
you can also use Allow (also a custom variable) as countRef, like this;
<Allow countRef="verifyapikey.Verify-API-Key-1.apiproduct.quotaLimit"/>
here's my quota policy;
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Quota async="false" continueOnError="false" enabled="true" name="Quota"> <DisplayName>Quota</DisplayName> <FaultRules/> <Properties/> <Interval ref="verifyapikey.Verify-API-Key-1.apiproduct.quotaInterval"/> <TimeUnit ref="verifyapikey.Verify-API-Key-1.apiproduct.quotaTimeUnit"/> <Allow countRef="verifyapikey.Verify-API-Key-1.apiproduct.quotaLimit"/> <Distributed>true</Distributed> <Synchronous>true</Synchronous> <PreciseAtSecondsLevel>false</PreciseAtSecondsLevel> <Identifier ref="request.header.apikey"/> </Quota>
I hope it works for you, good luck!
I am using Verify-API-Key as the name of verify api key policy.
@GAURAV that's strange, could you please upload and share your proxy revision? I can have a look.
Hi @Gaurav, I am the same issue. I would like to check if you are able to resolve the issue, if so, how? Thank you.
Hi @GAURAV - I tried to replicate the issue you are facing. And was able to replicate this. when the reference doesn't reach to the quota policy. You should cross validates the following things -
1- check if somehow the <Identifierref="request.header.tanentId"/> is getting removed with AM policy before the quota policy.
2- validate the variable references in your verify api key policy on the trace use those. which looks similar as in the screenshot.
Also, I am attaching the policy I have implemented with custom attributes.