Output Filtering

Describes the use of Path and Query interface fields to filter the response from a JSON (RESTful) Web service.

For Path and Query interface fields, at runtime, the output response body is filtered by any path- and query-parameter values received in the URI having parameter names that match the name of an output field in the response body. For example, for an operation defined as follows:

Path /cars/{make}

Where make is the name of a field defined within car

Output body array car items
Runtime request URI .../cars/ford?color=red&doors=4

Where color and doors are names of fields defined within car

The response body array excludes instances of car having make, color, and doors values that do not match the URI-specified values, and includes instances that do match the URI-specified values. In this example, the response body would include only red, four-door Fords.

If you do not want a Path or Query interface field to act as a filter on the output message, ensure that its name does not match the name of any output Body interface field.

In addition, to produce a response body containing only the specified fields along with their parent and child fields, and excluding all other defined fields from the response, you can use the special $fields built-in query parameter using the following syntax:

$fields=commaSeparatedListOfOutputFieldNames

Where commaSeparatedListOfOutputFieldNames is a comma-separated list of the fields you want to see in the response body. For example:

http://localhost:9003/temppath/CarTracker/1.0/cars?doors=2&fuelType=gasoline&$fields=make,model,price,fuelType

Produces a response body that contains values for the make, model, price, and fuelType fields only.

For more information, see Body, Path, and Query Fields and HTTP Method/Path.