REST URI convention - Singular or plural name of resource while creating it
Solution 1:
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)
Solution 2:
The premise of using /resources
is that it is representing "all" resources. If you do a GET /resources
, you will likely return the entire collection. By POSTing to /resources
, you are adding to the collection.
However, the individual resources are available at /resource. If you do a GET /resource
, you will likely error, as this request doesn't make any sense, whereas /resource/123
makes perfect sense.
Using /resource
instead of /resources
is similar to how you would do this if you were working with, say, a file system and a collection of files and /resource
is the "directory" with the individual 123
, 456
files in it.
Neither way is right or wrong, go with what you like best.