API / APIGEE Gateway Interview Questions
What is the ServiceCallout policy and when would you use it?
The ServiceCallout policy allows an Apigee proxy to make an additional HTTP call to an external service within the same request/response pipeline. The response from that external call is stored in a variable and can be used by subsequent policies, all before returning the final response to the client.
<!-- ServiceCallout: call an identity service to enrich the request --> <ServiceCallout name="SC.GetUserProfile"> <Request variable="userProfileRequest"> <Set> <Headers> <Header name="Authorization">Bearer {request.header.authorization}</Header> </Headers> </Set> </Request> <Response>userProfileResponse</Response> <HTTPTargetConnection> <URL>https://identity.internal.example.com/profile/{userId}</URL> </HTTPTargetConnection> </ServiceCallout> <!-- Then extract data from the callout response --> <ExtractVariables name="EV.ExtractProfile"> <Source>userProfileResponse</Source> <JSONPayload> <Variable name="userRole"> <JSONPath>$.role</JSONPath> </Variable> </JSONPayload> </ExtractVariables> <!-- Use the role in a condition to allow/deny access --> <!-- Condition: userRole = "admin" -->
| Use case | Description |
|---|---|
| Identity enrichment | Call an IdP to get user roles before authorisation decision |
| Data lookup | Fetch customer data from CRM to add to request |
| Token exchange | Exchange one token type for another with an external service |
| Webhook notification | Send event notification before/after backend call |
| Fraud check | Call a fraud detection service and block if flagged |
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...
