Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

[API] PUT_BY_ID

padewitte edited this page Nov 7, 2014 · 1 revision

PUT rest/{database}/{collection}/{id}

Replace a document by his {id} in the collection in URL with the body workload of the http request. This workload should contain a valid JSON object. Query the {collection name} in mongo, to find the document with the _id filed equas to the {id} in query parameter. Beware that in case of an update, the object is replaced entirely and the usage of MongoDB’s $modifiers is not permitted. The matching document is return as a JSON string in body workload.

Request parameters

Parameter Type Mandatory Comment

{database}

url

yes

database name

{collection}

url

yes

collection name

{id}

url

yes

id of document

body

body

no

Content of new document. If it _id field is set, ti has to be with the same value as id provided in url.

query

header

yes if no body provided

TODO

writeConcern

header

no

Write concern to use. Possible values : NONE, NORMAL, SAFE, JOURNALED, FSYNC_SAFE, REPLICA_SAFE

Result

Parameter Type Mandatory Comment

body

body

yes

MongoDB getLastError content.

Examples

Succesfuly delete quering by field name

curl -X PUT -d "{'_id' : '1', 'name' : 'Thibaut PINOT'} http://127.0.0.1:8080/kupra/rest/db/col/

{
  serverUsed: "127.0.0.1:27017",
  ok: 1,
  n: 1,
  updatedExisting: true
}