shabda
shabda

Reputation: 1758

Append HTTP verb

I have (JSON for) a resource like this at /api/foo/1/

{name: "foo", bar_pks: [10, 11, 12]}

Now I want to add an API for appending to bar_pks. There is no HTTP verb for appending I can find. If I do a patch to /api/foo/1/ with {bar_pks: [13]}, it will overwrite, not append.

  1. Is there a verb more consistent with appending?
  2. If I modify patch for this resource to always do an append, will it come to bite me later?

(I am using Django and Tastypie, but would prefer a language agnostic answer.)

Upvotes: 0

Views: 255

Answers (1)

Eric Stein
Eric Stein

Reputation: 13682

Is there a compelling reason not to do the append on the client side and use a PUT/PATCH to send the updated value back to the server?

I see a couple of options if you're dead-set on doing this:

  1. A POST to a new URI which gets interpreted as a an append to the list.
  2. A query parameter on the PATCH which indicates that the changes should be appended rather than overwrite.

Neither of these are good options, and I do not endorse using them.

Upvotes: 2

Related Questions