REST URI convention – Singular or plural name of resource while creating it

naming-conventionsresourcesresturi

I'm new to REST and I've observed that in some RESTful services they use different resource URI for update/get/delete and Create. Such as

  • Create – using /resources with POST method (observe plural) at some places using /resource (singular)
  • Update – using /resource/123 with PUT method
  • Get – Using /resource/123 with GET method

I'm little bit confused about this URI naming convention. What should we use plural or singular for resource creation? What should be the criteria while deciding that?

Best Solution

For me is better to have a schema that you can map directly to code (easy to automate), mainly because code is what is going to be at both ends.

GET  /orders          <---> orders 
POST /orders          <---> orders.push(data)
GET  /orders/1        <---> orders[1]
PUT  /orders/1        <---> orders[1] = data
GET  /orders/1/lines  <---> orders[1].lines
POST /orders/1/lines  <---> orders[1].lines.push(data)