Walery Strauch Walery Strauch - 2 months ago 15
HTTP Question

REST Array manipulation best practice

I have full access to foo resource via REST:

"name": "foo",
"tags": [

I would like to delete

Usually I would
GET \foo
PUT \foo
it back without
In this case this object is small, so this is ok.

But let's assume it's much bigger. For this case I don't like to download and upload this data. After some google research I found out http PATCH. I looks like exactly what I need.

My request in PATCH way is now

PATCH /foo/tags?op={add|delete}

To delete I would use:

PATCH /foo/tags?op=delete

With this data:

"value": "tag01"

There are now two thinks that I don't like:

  • query field
    - are there some deafult names described in rfc or smth. like this

  • member
    in request data - this is also freely chosen name

It doesn't look correct to me.

Is there some other way to manipulate arrays via REST?

Are there some name conventions to do it in PATCH way?


The payload of a PATCH should contain "instructions describing how a resource currently residing on the origin server should be modified to produce a new version". All information should be passed in the payload and not in query-params.

For instance you could send:

PATCH /foo

    "op": "remove",
    "path": "/tags/0" 

Path /tags/0 points to the first element of the array. The remaining elements should be shifted to the left.

See the JSON Patch draft for more details.