How to handle the fault generated by security polices.

plvndinesh
Participant II

I attached a Security policy(VerifyApi key) to my ProxyEndpoint(request) , when i am not provind key it is throwing error like

{"fault":{"faultstring":"Failed to resolve API Key variable request.queryparam.apikey","detail":{"errorcode":"steps.oauth.v2.FailedToResolveAPIKey"}}}

I need handle this fault and generate user understandble message.

note:I tried in handling faultrules but it not worked.  
0 1 252
1 REPLY 1

amitkumar2091
Participant III

Fault Rules should be working , are you sure you are using right fault name to catch provided scenario

It should be

<FaultRules>
        <FaultRule name="invalid-api-key">
            <Step>
                <Name>AM-FailedToResolveAPIKey</Name>
                <Condition>(fault.name = "FailedToResolveAPIKey")</Condition>
            </Step>
        </FaultRule>
    </FaultRules>

Please look at apigee docs for fault handling (https://docs.apigee.com/api-platform/fundamentals/fault-handling). This will provide you step by step guide for fault handling including an example for mentioned scenario.

If you are still facing issue , please update your question with more implementation details , it will help us understand your problem better.