Updated Branches:
  refs/heads/1924-add-an-example-for-updating-a-document-with-PUT [created] 
3b6301fe3


Docs: add the example for updating a document with put in the
section PUT /{db}/{docid} with both variants in sending
the rev with the If-Match header and as a query parameter.

There is also a section 'Updating an Existing Document'
below in common.rst. Imho this is duplicated content now
so it could be deleted there. But it does also not hurt to
have it there again.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/3b6301fe
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/3b6301fe
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/3b6301fe

Branch: refs/heads/1924-add-an-example-for-updating-a-document-with-PUT
Commit: 3b6301fe324d54f092f36a50ae9bf0456ebda67f
Parents: b9fbec6
Author: Andy Wenk <[email protected]>
Authored: Fri Nov 8 23:50:05 2013 +0100
Committer: Andy Wenk <[email protected]>
Committed: Fri Nov 8 23:50:05 2013 +0100

----------------------------------------------------------------------
 share/doc/src/api/document/common.rst | 68 ++++++++++++++++++++++++++++--
 1 file changed, 65 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/3b6301fe/share/doc/src/api/document/common.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/api/document/common.rst 
b/share/doc/src/api/document/common.rst
index 0a1e28c..5734f07 100644
--- a/share/doc/src/api/document/common.rst
+++ b/share/doc/src/api/document/common.rst
@@ -196,7 +196,7 @@
   :code 409: Document with the specified ID already exists or specified
     revision is not latest for target document
 
-  **Request**:
+  **Request (create new document)**:
 
   .. code-block:: http
 
@@ -216,7 +216,7 @@
         "name": "Spaghetti with meatballs"
     }
 
-  **Response**:
+  **Response (create new document)**:
 
   .. code-block:: http
 
@@ -235,6 +235,68 @@
         "rev": "1-917fa2381192822767f010b95b45325b"
     }
 
+  **Request (update existing document)**:
+
+  .. code-block:: http
+
+    PUT /recipes/SpaghettiWithMeatballs?rev=1-917fa2381192822767f010b95b45325b 
HTTP/1.1
+    Accept: application/json
+    Content-Length: 196
+    Content-Type: application/json
+    Host: localhost:5984
+
+    {
+        "description": "An Italian-American dish that usually consists of 
spaghetti, tomato sauce and meatballs.",
+        "ingredients": [
+            "spaghetti",
+            "tomato sauce",
+            "meatballs",
+            "mozarella"
+        ],
+        "name": "Spaghetti with meatballs"
+    }
+
+  Alternatively, instead of the ``rev`` query parameter you may use the
+  :header:`If-Match` header:
+
+  .. code-block:: http
+
+    PUT /recipes/SpaghettiWithMeatballs HTTP/1.1
+    Accept: application/json
+    Content-Length: 196
+    Content-Type: application/json
+    If-Match: 1-917fa2381192822767f010b95b45325b
+    Host: localhost:5984
+
+    {
+        "description": "An Italian-American dish that usually consists of 
spaghetti, tomato sauce and meatballs.",
+        "ingredients": [
+            "spaghetti",
+            "tomato sauce",
+            "meatballs",
+            "mozarella"
+        ],
+        "name": "Spaghetti with meatballs"
+    }
+
+  **Response (update existing document)**:
+
+  .. code-block:: http
+
+    HTTP/1.1 201 Created
+    Cache-Control: must-revalidate
+    Content-Length: 85
+    Content-Type: application/json
+    Date: Wed, 14 Aug 2013 20:34:23 GMT
+    ETag: 2-faf1e73a94ff04ebede600f173ca0412
+    Location: http://localhost:5984/recipes/SpaghettiWithMeatballs
+    Server: CouchDB (Erlang/OTP)
+
+    {
+        "id": "SpaghettiWithMeatballs",
+        "ok": true,
+        "rev": "2-faf1e73a94ff04ebede600f173ca0412"
+    }
 
 .. http:delete:: /{db}/{docid}
 
@@ -279,7 +341,7 @@
     Accept: application/json
     Host: localhost:5984
 
-  Alternatively, instead of ``rev`` query parameter you may use
+  Alternatively, instead of the ``rev`` query parameter you may use the
   :header:`If-Match` header:
 
   .. code-block:: http

Reply via email to