Let's take the following API:
One of the things that I'm always a bit unclear about is when updating the /posts/{id}
item. If a post consists of:
- ID
- Title
- Author
- PostedAt
- Body
What if we want to wipe out a previous post and update it with the new post (that is, something like getByID.update(title, author, body)
-- would this be done via a PUT
request or a POST
request? Would it ever make sense to POST
to a /posts/{id}
or does a POST
essentially mean it creates a new entry, whereas a PUT
only updates an existing entry via its PK -- i.e., a POST
is like a INSERT
in SQL and a PUT
is like an UPDATE
in SQL.
Additionally, what if there is something like a List field? For example, /posts/{id}/tags
, where tags could be something like programming
, c++
, rest
. What if someone performed a delete
operation here -- would it be deleting all the tags, or just a single tag?