RESTful operations to query data
When defining a resource-oriented RESTful service, do you consider it a good idea to define an explicit operation (verb) to request data?
It seems obvious and easy to map CRUD operations in a resource oriented RESTful service using HTTP for operations like PUT, GET, POST, and DELETE, but how should operations that request multiple resources be displayed - using a new operation called QUERY 'or still use 'GET', which returns a collection of resources.
I am interested in people's opinions and experiences ...
a source to share
REST is about resources. What resource will be returned to your request? Data set? How is this set determined? How is it parameterized? This should define the URL you will be using with the GET operation:
GET /customers would retrieve all customers
GET /customers?q=<query> would retrieve all customers matching the query
EDIT: It's not really clear to me
Thinking that the request is about fetching a resource that is a collection of clients (for example), I started to wonder about well-defined subsets of the collection of all clients. Consider things like:
GET /customers/state/MA Retrieve all customers in Massachusetts
GET /customers/country/UK All in the UK
GET /customers/country/UK/postalcode/001-234 All in that postal code in the UK
Resources like these make sense to me as clearly identified resources and not as requests. I would continue to use the query string to retrieve an arbitrary set of clients, but where there is a natural clients section, I could specify that in the URL space.
Recall that the GET operation is for idempotent operations and is designed to promote caching. Responding to these queries should allow some reasonable amount of caching (maybe one day). This will allow the client computer or proxy server to cache the result set for a specified period of time, keeping the server's travel rounded off.
a source to share