The POST
verb can be used to either create a resource or update an existing resource. All HTTP aware components assume that POST
will make a change to the state of the system and will not repeat a POST
request in case of an error.
When we perform a POST
request to the RavenDB's docs
structure, it will create the specified document and allow RavenDB to assign a unique ID to it. We have to specify the document data in JSON format and will not specify the document ID. It is important to note that a repeated POST
request for the same document will create that document with a new ID each time.
The POST
request URL is very similar to the PUT
request URL with the difference that we do not specify the document ID in the URL.
A POST
request to a document URL is considered as an invalid request and RavenDB will return error status code. Otherwise, if the POST
request succeeded, the server response will contain the generated ID for the document and an HTTP response code:
HTTP Method | ... |
---|