The REST service URI supports query, path, and form parameters.
Note: You cannot use the Java reserved words as the
parameters such as int, char, or boolean.
- Path parameter
- Path parameters are used to identify entities, represent
hierarchies or to provide data to a resource. They are not intended to
filter or restrict information like query parameters. A resource can have
more than one path parameter to represent hierarchical data. The curly
braces are only used to identify path parameter values.
The illustration below provides URI examples with path parameters:
/customers/{customer-id}, where
{customer-id} indicates it is a
path parameter, and customer-id is
the path parameter value.
/customers/{customer-id}/orders/{order-id}, wherein
customer-id and order-id are the two path parameters
defined in the URI.
You can add a path parameter
using the New REST Resource dialog
- Query parameter
- Query parameters represents search criterion and restricts
the result list like a filter. They are not intended to identify entities of
a resource or to select the representation like path parameters. A query
parameter starts with a "?". A resource
can have more than one query parameter that is separated with "&".
The illustration
below provides URI examples with query parameter:
/customers/{customer-name}/info?zip=[cust-zip] , where
? indicates that it is a query
parameter, zip is the parameter
name, and [cust-zip] is the query
value.
/customers/{customer-name}/info?zip=cust-zip&name=cust-name,
wherein zip and cust-name are the two query parameters
defined in the URI.
Here the customer zip code is
passed as a query parameter using which the query returns the matching
customer names.
Note: In a resource URI, you
must always specify a query parameter after a path parameter. Any
path parameter specified after a query parameter will be handled as
a query parameter.
You can add a query
parameter using either the New REST Resource dialog or Managing nodes
- Form parameter
- Form parameters can be used with only the PUT and POST
verbs. You can add a form parameter using the Add Node
dialog.