I like this approach, but I would avoid the query params. Query
params, while enticing, really shouldn't be used to communicate
resource state or transitions. You could accomplish this same thing
like this:
PUT /invitations/{id}
{ "accept" : true }
Generally speaking, PUT should be used to update an existing resource;
it's existing because it has an ID.
To create the invitation you would POST to the invitations resource:
POST /invitations
{ "name": "Picnic", "date" : "..." }
The response would be:
201 CREATED
Location: /invitations/ID
On Apr 10, 5:24 pm, Greg Brail <
g...@apigee.com> wrote:
> What about the "action" pattern that I've seen on a few APIs, combined with
> POST, like this:
>
> GET /invitations/{id} : Read the invite
> POST /invitations/{id}?action=accept : Accept it
> POST /invitations/{id}?action=decline : Decline it
> DELETE /invitations/{id} : Rescind the invitation (only authorized for the
> organizer)
> PUT /invitations/{id} : Update it (add a dial-in number, directions, etc).
>
> With this pattern, "/invitations/{id}" unambiguously refers to a single
> invite, which you can manipulate using the standard verbs or not as you
> extend your API. The POST with the "action" parameter is essentially a
> partial update of the invite, with semantics that depend on the action.
> (Yes, it's like a method call, so shoot me ;-)
>
> You could also use PATCH for that if you wanted to be fancy.
>