問題文
A support API already exposes /tickets. The team now needs an operation that creates a new comment underneath an existing ticket. Which method and resource combination follows REST conventions?
選択肢
- PATCH to /tickets/{ticketId} with the comment text in the body, because adding a comment changes the ticket and PATCH expresses a partial change to an existing resource without requiring a new resource to be defined.
- POST to /tickets/{ticketId}/comments, because the comment is a new subordinate resource created under a known ticket.
- PUT to /tickets/{ticketId}/comments, because PUT is the method used for writes, and creating a comment writes data into the collection.
- POST to /comments with the ticket number as a query parameter.