Pick the fix
Which endpoint set follows REST conventions for creating and reading orders?
Hint 1 of 1
What does the HTTP method already say?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A POST /orders returns 201 with Location: /orders/42; GET /orders/42
Correct. The collection takes the POST; the new resource gets its own URL.
In REST the URL names a thing and the HTTP method says what to do with it. Creating means POSTing to the collection, and the server, which picks the id, returns the new URL in Location so the client can GET it.
Why not the others?
- B
POST /createOrder;GET /getOrder?id=42. Verbs in paths duplicate what the method already says. - C
GET /orders/create?item=…. GET must not change state; caches and crawlers can trigger it. - D
PUT /orderswith the new order in the body. PUT replaces the target resource; the client doesn't know the new id.