aboutsummaryrefslogtreecommitdiff
path: root/docs/api
diff options
context:
space:
mode:
authorStephen Finucane <stephen@that.guru>2017-06-01 14:48:22 +0100
committerStephen Finucane <stephen@that.guru>2018-12-25 19:59:36 +0000
commit2782fcfd581bd32e050c9237de29f00cd5d7a89e (patch)
treeddc5a439001f9658635f74d81465767b32d2ea74 /docs/api
parent1913800e1fe5806d0dfac2986b08c165c2577541 (diff)
downloadpatchwork-2782fcfd581bd32e050c9237de29f00cd5d7a89e.tar
patchwork-2782fcfd581bd32e050c9237de29f00cd5d7a89e.tar.gz
docs: Detail JSON PATCH requests
It turns out it is possible to make PATCH requests with JSON bodies rather than form-encoded data - you just need to include a Content-Type header. Document this. Signed-off-by: Stephen Finucane <stephen@that.guru>
Diffstat (limited to 'docs/api')
-rw-r--r--docs/api/rest.rst19
1 files changed, 17 insertions, 2 deletions
diff --git a/docs/api/rest.rst b/docs/api/rest.rst
index ea43095..6b11ac7 100644
--- a/docs/api/rest.rst
+++ b/docs/api/rest.rst
@@ -160,13 +160,28 @@ string parameters:
$ curl 'https://patchwork.example.com/api/patches?state=under-review'
For all other types of requests, including ``POST`` and ``PATCH``, these
-parameters should be passed as form-encoded data:
+parameters should be encoded as JSON with a ``Content-Type`` of
+``application/json`` or passed as form-encoded data:
.. code-block:: shell
- $ curl -X PATCH -F 'state=under-review' \
+ $ curl -X PATCH \
+ --header "Content-Type: application/json" \
+ --data '{"state":"under-review"}' \
+ 'http://localhost:8000/api/patches/123/'
+
+.. code-block:: shell
+
+ $ curl -X PATCH \
+ --form 'state=under-review' \
'https://patchwork.example.com/api/patches/123'
+.. important::
+
+ If you do not include the ``Content-Type`` header in your request, you will
+ receive a ``HTTP 200 (OK)`` but the resource will not be updated. This
+ header **must** be included.
+
.. versionchanged:: 2.1
API version 1.1 allows filters to be specified multiple times. Prior to