PATCH: Partially updates document in the collection
Normally the document with the matching identifier will be retrieved from the collection and it will be patched by all specified fields from the JSON request body. Finally 200 HTTP status code will be returned.
If the document has been found in the collection but it had already been deleted, 410 HTTP status code is to be returned.
When no document with identifier has been found in the collection, then the operation ends with 404 HTTP status code.
You can also specify If-Unmodified-Since request header including your timestamp of document's last modification. If the document has been modified by somebody else on the server afterwards (and you do not know about it), the 412 HTTP status code is returned cancelling the update operation. You can use this feature to prevent race condition problems.
PATCH operation can save some bandwidth for incremental document updates in comparison with GET - UPDATE operation sequence.
While patching the document, the field modifiedBy is automatically set to the authorized subject's name.
This operation provides autopruning of the collection (if autopruning is enabled).
This operation requires update permission for the API and the collection (e.g. api:treatments:update)
Headers
Timestamp (defined with respect to server's clock) of the last document modification formatted as:
<day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
If this header is present, the operation will compare its value with the srvModified timestamp of the document at first and the operation result then may differ. The srvModified timestamp was defined by server's clock.
Example:
<pre>If-Unmodified-Since: Wed, 17 Oct 2018 05:13:00 GMT</pre>Request body
Example request
{
"identifier": "53409478-105f-11e9-ab14-d663bd873d93",
"date": 1525383610088,
"utcOffset": 120,
"app": "xdrip",
"device": "dexcom G5",
"_id": "58e9dfbc166d88cc18683aac",
"srvCreated": 1525383610088,
"subject": "uploader",
"srvModified": 1525383610088,
"modifiedBy": "admin",
"isReadOnly": true
}Response
The request was successfully processed
Example response
{
"status": 200
}