[openstack-dev] [api] Usage of the PATCH verb

Brian Rosmaita brian.rosmaita at RACKSPACE.COM
Fri Dec 12 22:39:22 UTC 2014

The Images API v2 has been using PATCH to update an image record for quite a long time now.  We pretty much follow the IETF docs.  Here's how it's documented:


And here's the info about the media type used for the request body:


Not surprisingly, we feel that this is the correct way to implement PATCH!


From: Amit Gandhi [amit.gandhi at RACKSPACE.COM]
Sent: Friday, December 12, 2014 3:17 PM
To: OpenStack Development Mailing List (not for usage questions)
Subject: [openstack-dev] [api] Usage of the PATCH verb


We are currently using PATCH in the Poppy API to update existing resources.  However, we have recently had some discussions on how this should have been implemented.

I would like to get the advise of the Openstack Community and the API working group on how PATCH semantics should work.

The following RFC documents [1][2] (and a blog post [3]) advise the using PATCH as the following:

2.1.  A Simple PATCH Example

   PATCH /file.txt HTTP/1.1
   Host: www.example.com<http://www.example.com>
   Content-Type: application/example
   If-Match: "e0023aa4e"
   Content-Length: 100

{ "op": "test", "path": "/a/b/c", "value": "foo" },
{ "op": "remove", "path": "/a/b/c" },
{ "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] },
{ "op": "replace", "path": "/a/b/c", "value": 42 },
{ "op": "move", "from": "/a/b/c", "path": "/a/b/d" },
{ "op": "copy", "from": "/a/b/d", "path": "/a/b/e" }

Basically, the changes consist of an operation, the path in the json object to modify, and the new value.

The way we currently have it implemented is to submit just the changes, and the server applies the change to the resource.  This means passing entire lists to change etc.

I would like to hear some feedback from others on how PATCH should be implemented.


Amit Gandhi
- Rackspace

[1] https://tools.ietf.org/html/rfc5789
[2] http://tools.ietf.org/html/rfc6902
[3] http://williamdurand.fr/2014/02/14/please-do-not-patch-like-an-idiot/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20141212/384684b8/attachment.html>

More information about the OpenStack-dev mailing list