API / APIGEE Gateway Interview Questions
What is the ExtractVariables policy and how does it work with flow variables?
The ExtractVariables policy extracts content from HTTP messages (headers, query parameters, URI path, JSON body, XML body, form parameters) and stores the values in named flow variables. These variables can then be referenced in conditions and other policies throughout the proxy.
<!-- Extract from JSON request body --> <ExtractVariables name="EV.ExtractBody"> <Source>request</Source> <JSONPayload> <Variable name="orderId"> <JSONPath>$.order.id</JSONPath> </Variable> <Variable name="customerId"> <JSONPath>$.order.customer.id</JSONPath> </Variable> </JSONPayload> </ExtractVariables> <!-- Extract from URI path pattern: /orders/{orderId}/items/{itemId} --> <ExtractVariables name="EV.PathVars"> <Source>request</Source> <URIPath> <Pattern ignoreCase="true">/orders/{orderId}/items/{itemId}</Pattern> </URIPath> </ExtractVariables> <!-- Extract from query parameter --> <ExtractVariables name="EV.QueryParam"> <Source>request</Source> <QueryParam name="customerId"> <Pattern>{customerId}</Pattern> </QueryParam> </ExtractVariables> <!-- Now use the variable in a condition or another policy --> <!-- Example: add the orderId as a backend header --> <AssignMessage name="AM.InjectOrderId"> <Set> <Headers> <Header name="x-order-id">{orderId}</Header> </Headers> </Set> </AssignMessage>
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...
