API / APIGEE Gateway Interview Questions
What are Apigee flow variables and how do you work with them?
Flow variables are runtime key-value pairs that carry contextual information through the Apigee request/response pipeline. They are the primary means by which policies share data with each other. Some variables are automatically populated by Apigee; others are created by policies like ExtractVariables or AssignMessage.
| Variable | Value | Set by |
|---|---|---|
| request.verb | HTTP verb (GET, POST, etc.) | Apigee (always) |
| request.path | Request URL path | Apigee (always) |
| proxy.pathsuffix | Path after the proxy base path | Apigee (always) |
| request.header.{name} | Named request header value | Apigee (always) |
| request.queryparam.{name} | Named query parameter value | Apigee (always) |
| response.status.code | HTTP status code from backend | Apigee (always) |
| target.url | The URL Apigee sends to backend | Apigee / can be overridden |
| client.ip | Client's IP address | Apigee (always) |
| system.timestamp | Current epoch timestamp (ms) | Apigee (always) |
| environment.name | Current environment name | Apigee (always) |
<!-- Reference a flow variable in policy XML using curly braces --> <AssignMessage name="AM.SetHeader"> <Set> <Headers> <!-- Reference built-in variable --> <Header name="x-request-path">{request.path}</Header> <!-- Reference variable set by ExtractVariables --> <Header name="x-order-id">{orderId}</Header> <!-- Reference verifyapikey variable --> <Header name="x-client-id">{verifyapikey.VerifyAPIKey.client_id}</Header> </Headers> </Set> </AssignMessage> <!-- Reference in a condition expression (no braces needed) --> <Flow name="OrdersFlow"> <Condition>request.verb == "GET" and proxy.pathsuffix MatchesPath "/orders/**"</Condition> </Flow> <!-- Set a variable using JavaScript --> // context.setVariable("myCustomVar", "hello"); // context.getVariable("request.header.x-api-key"); // var statusCode = context.getVariable("response.status.code");
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...
