Think of a purchase as a business entity or resource in a RESTful dictionary. Moreover, the purchase purchase actually creates a new resource. So:
POST /api/purchase
will place a new order. Details (user, car, etc.) Must refer to an identifier (or URI) inside the content sent to this address.
It doesn’t matter that ordering a car is not just a simple INSERT in the database. Actually, REST is not viewing your database tables as CRUD operations. Logically, you create an order (purchase), but the server side can perform as many processing steps as it wants.
You can even abuse HTTP even more. Use the Location header to return a link to the newly created order, carefully select HTTP response codes to inform users about problems (on the server or on the client side), etc.
Tomasz Nurkiewicz Jul 27 '11 at 19:42 on 2011-07-27 19:42
source share