On Wednesday 2009.01.21, at 10:56 , Jean-Philippe Steinmetz wrote:
[...]
> If you are both suggesting using POST to add an entry why use PUT  
> then? It seems to make PUT somewhat irrelevant unless performing an  
> update.

This is a coming misunderstanding in coming to REST.  For more  
information, you might want to get e.g., the O'Reilly REST book.

Basically, in your example, using PUT would be in the client was  
responsible for creating the id.  Using POST, the client is asking the  
server to create the resource on your behalf and so the result of the  
POST is the location/ID of the new resource.

> I'm going to have to do some rethinking. I'm mainly using this rest  
> service for passing serialized objects back and forth between the  
> service and clients. I had originally imagined that the difference  
> between the cars and car was merely that car returned a single full  
> car object (serialized of course) while cars returned an array or  
> list (also full objects) but I can see where you'd think otherwise.  
> The way you define a list below would require some extra processing  
> that I don't necessarily do when working with serialization. Has  
> anyone else come across this kind of a scenario?

I don't see any problem in what you're wanting to do.  Singular &  
plural/aggregates that work hand-in-hand are quite common.  Whether  
you do that through a single resource or two URIs which map to a  
single resource or two different resources depends on what all your  
clients need to be able to do easily.

That said, I will say that your idea that doing a GET on /car/ should  
return "a list of all cars" is probably a dangerous assumption to  
build into your api.  I.e., what happens when you have a million cars  
in your system?  A better default would be to have return a bunch of  
meta-data so that the clients can discover various ways to get at the  
underlying information (total number of cars, link to how to view cars  
by make, model, year, VIN, etc.).

Though, if you're really not just talking about car/cars, it might  
help us understand if you tell us what you're actually passing around.

Take care,
John

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1042905

Reply via email to