API / APIGEE Gateway Interview Questions
How does fault handling and error management work in Apigee?
Apigee provides a structured fault handling mechanism through FaultRules and DefaultFaultRule. When a policy raises an error, Apigee exits the normal flow and enters the error flow, where you can customise the error response returned to the client.
<!-- FaultRule: handle specific policy error --> <ProxyEndpoint name="default"> <FaultRules> <!-- Handle quota exceeded specifically --> <FaultRule name="QuotaExceeded"> <Condition>fault.name = "QuotaExceeded"</Condition> <Step><Name>AM.QuotaExceededResponse</Name></Step> </FaultRule> <!-- Handle invalid API key --> <FaultRule name="InvalidApiKey"> <Condition>fault.name = "InvalidApiKey"</Condition> <Step><Name>AM.UnauthorisedResponse</Name></Step> </FaultRule> </FaultRules> <!-- Catch-all for any unhandled fault --> <DefaultFaultRule name="DefaultFaultRule"> <Step><Name>AM.GenericErrorResponse</Name></Step> <AlwaysEnforce>true</AlwaysEnforce> </DefaultFaultRule> </ProxyEndpoint> <!-- Custom error response policy --> <AssignMessage name="AM.QuotaExceededResponse"> <AssignTo createNew="true" type="response"/> <Set> <StatusCode>429</StatusCode> <ReasonPhrase>Too Many Requests</ReasonPhrase> <Headers><Header name="Content-Type">application/json</Header></Headers> <Payload contentType="application/json">{ "error": "rate_limit_exceeded", "message": "You have exceeded your quota.", "retry_after": "3600" }</Payload> </Set> </AssignMessage> <!-- Key fault variables: fault.name -- e.g. "QuotaExceeded", "InvalidApiKey" fault.type -- "policy" or "messaging" error.message -- the error message string -->
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
