On Sun, Mar 23, 2008 at 7:56 PM, Ian Clarke <[EMAIL PROTECTED]> wrote: > When is it appropriate to use a query string to pass parameters to a > REST API call? > > For example, why is: > > http://blah/user/1234 > > better than: > > http://blah/user?id=1234 > > ?
I depends on the context really. For your example you are referencing a particular user. From a REST point of view, the user is not a query but a resource, so it is preferred for the URI to not have a query parameter. The non-query part of the URI identifies 'what', and the query part usually is only modifying the context of the 'what' you are asking for. The Restlet FAQ has some good links: http://www.restlet.org/about/faq#04 > > I'm guessing that if I have a GET request which can return a list of a > variable length (such as a search), then a GET parameter should be > used to indicate how many results should be provided - is this > correct? People typically use query parameters to control the number of requests, but this usage comes from the fact that they are adding context to the resource--as a URI--itself. > > In the event that it is appropriate to use a GET parameter, what is > the best way to extract it from a Request? http://www.restlet.org/documentation/1.0/tutorial#part10 has one way to push the query parameters into the Request's attributes, available via getRequest().getAttributes(). .. Adam