Skip to Content
avatar image
Former Member

Using FaultRules in SAP API Management

Hello,

I am using some policies(oAuth,SpikeArrest) in proxy preflow.To handle the errors gracefully and provide custom messages to users, i want to use fault rules. But in SAP API Management running on HCP, i am not able to find any option to add the fault rules.

Scenario: Suppose the oAuth token given in the client request is invalid and instead of sending the default message generated by the oAuth policy, i want to send a custom message.

Note: I am new to SAP API management and have used apigee before.I am using trial version of SAP API Management hosted on HCP.

Any help is appreciated.

Gagandeep Singh

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Feb 24, 2017 at 02:02 AM

    Hi Gagandeep,

    Would this be possible to handle with the Raise Fault policy? E.g. set oAuth policy to "ContinueOnError = true" then add a Raise Fault policy afterwards with the Condition String for Raise Fault set to activate when API error occurs for invalid_access_token?

    Then inside the Raise fault policy you could specify your custom error message. (If your custom message is specific to invalid token, then you might want an error handler for all other error conditions than invalid token as well afterwards).

    Regards,
    Elijah

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Elijah,

      Thanks for your reply. Yes, the solution you have given is possible and have already implemented the same.

      But, the problem here is,

      1. spikeArrest policy can fail due to lot of reasons(example: apikeArrest limit exceeded or invalid message weight or the value of spike arrest rate is not resolved, when given as ref) and the conditions for each will be different. I could not find reference to the different faults which the spike arrestpolicy will be generating in the documentation here.

      Is there any other documentation or am I refering to wrong documentation?

      Note: I tried using (fault.name Matches "SpikeArrestViolation") and (ratelimit.SA-SpikeArrestPolicy.failed=true) but both are not working

      2. In case any of my policy fails(assignMessage or Extract variable, etc..), I don't want to show give the default response given by policy to the user. To mask/generalize it, i want to give something like 500, Internal Server Error. Is there any other way to do this without putting continueOnError="true" on each policy and handling the same using raise fault as the number of policies are quite large. (I am looking for something similar to defaultFaultRule)

      Thanks in advance

      Gagandeep Singh