Extract REST request attributes

Overview

This filter extracts the values of query string parameters and/or HTTP headers from a REST request and stores them in separate message attributes. The request can be an HTTP GET or POST request. This filter is in the Attributes category in Policy Studio. For details on creating a REST request, see Create REST Request.

Example REST request

The following example shows an incoming REST request with query string and HTTP headers:

POST /services?name=Niall&location=Dublin&location=Pembroke%20St HTTP/1.1
Host: mail.google.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.15) 
Gecko/20110303 Firefox/3.6.15
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Using this example, the Extract REST Request Attributes filter generates the following attributes:

http.header.Host = mail.google.com
http.header.User-Agent = Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.15) 
Gecko/20110303 Firefox/3.6.15
http.header.Accept = text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
http.header.Accept-Language = en-gb,en;q=0.5
http.header.Accept-Encoding = gzip,deflate
http.header.Accept-Charset = ISO-8859-1,utf-8;q=0.7,*;q=0.7

http.querystring.name = Niall
http.querystring.location.1 = Dublin
http.querystring.location.2 = Pembroke St

[Note] Note

For multi-valued query string parameters (for example, location), each value is given an incremental index. For example, the multi-valued location parameter results in the creation of the http.querystring.location.1 and http.querystring.location.2 message attributes.

This filter extracts all parameters from an incoming REST request, and stores them in separate message attributes so that they can be validated easily, without needing to iterate through the set of http.headers.

Configuration

Configure the following fields on the Extract REST Request Attributes screen:

Name:

Enter an appropriate name for this filter.

Request Querystring:

Select whether to extract the values of query string parameters from an HTTP POST or GET request. These are simple name-value pairs (for example, Name=Joe Bloggs). This setting is selected by default.

HTTP Headers:

Select whether to extract the HTTP header values from an HTTP POST or GET request (selected by default).