Skip to content
Latest commit 5cad8ad @WWitman WWitman rearrange

Extract and assign variables

Sample use case

Extract data into flow variables from the response message. Assign extracted variables to HTTP response headers.


This sample uses these policies:

  • alt text Extract Variables: To pull subsets of data from the response body.
  • alt text XML to JSON: To convert the response from XML to JSON.
  • alt text Assign Message: To assign extracted data to response headers.


The target API is a service that returns weather data. We attach policies to the response flow to demonstrate how to extract and assign variables:

  1. Extract variables from the XML response sent from the target. We use XPath syntax to identify the data to extract. The extracted data includes weather location, condition, today's forecast, and tomorrow's forecast.
  2. Convert the response payload from XML to JSON.
  3. Extract more variables from the converted JSON payload. We use JSONPath syntax to identify the data to extract. The extracted data includes the weather description and humidity.
  4. Assign the extracted variables to HTTP response headers.

Set up, deploy, invoke

See the main project README file for information about setting up, deploying, and invoking sample proxies.


This screen shot from the Apigee Edge trace tool shows the placement of the policies used in this sample.

alt text

More information

Policy used in this sample

Related policies

Related topics

Ask the community

alt text


Update /setup/ with your environment details

Import and deploy sample project

To deploy, run $ sh

To test, run $ sh

Get help

For assistance, please use Apigee Support.

Copyright © 2014, 2015 Apigee Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Something went wrong with that request. Please try again.