Get a Document
Performing a GET operation on a specific document resource retrieves the user defined JSON elements and system properties of the document.
While consistency level is defined at the database account level during account creation, read consistency can be overridden to suffice the need of the application. The override is set per GET operation by setting the x-ms-consistency-level header to the desired level. The consistency override can only be the same or weaker than the level that was set during account creation. Consistency levels from weakest to strongest is Eventual, Session, Bounded Staleness and Strong.
For information on consistent level, see Consistency levels in DocumentDB.
Method |
Request URI |
HTTP Version |
GET |
https://{databaseaccount}.documents.azure.com/dbs/{_rid-db}/colls/{_rid-col}/docs/{_rid-doc} |
HTTP/1.1 |
Note that the {databaseaccount} is the name of the DocumentDB account created under your subscription. The {_rid-db} value is the system generated resource ID of the database. The {_rid-col} value is the system generated resource UD of the collection. The {_rid-doc} value is the resource ID of the document to be retrieved.
Standard Header |
Description |
Authorization |
Required. The authentication type and signature token. Both master key and resource tokens are allowed for this operation. For more information, see Access Control on DocumentDB Resources. |
Accept |
Optional. The response payload in standard JSON format. The client must be able to accept the response body in standard JSON format. |
User-Agent |
Optional. The client user agent performing the request. The recommended format is {user agent name}/{version}. For example, the DocumentDB .NET SDK sets the User-Agent string to Microsoft.Document.Client/1.0.0.0. |
Custom Header |
Description |
x-ms-date |
Required. The date of the request, per RFC 1123. The date is expressed in Coordinated Universal Time format, e.g. Fri, 08 Apr 2015 03:52:31 GMT. |
x-ms-version |
Optional. The version of the DocumentDB REST service. The latest version is used when the header is not provided. For more information, see Versioning for DocumentDB REST API. |
x-ms-consistency-level |
Optional. This is the consistency level override. The valid values are: Strong, Bounded, Session or Eventual. The override level must be the same or weaker than the level that was set during account creation. |
None.
GET https://contosomarketing.documents.azure.com/dbs/-yI8AA==/colls/-yI8AKNuyAA=/docs/-yI8AKNuyAANAAAAAAAAAA== HTTP/1.1
x-ms-date: Mon, 18 Apr 2015 07:39:23 GMT
authorization: type%3dmaster%26ver%3d1.0%26sig%3dJith8Kqorph9kuifIQZ2P%2fbQryAZhe%2bw62rML04YpoE%3d
x-ms-version: 2015-04-08
Host: contosomarketing.documents.azure.com
This operation returns the following common headers. There may be additional standard and common headers returned.
Standard Header |
Description |
Content-Type |
The Content-Type is application/json. DocumentDB always return the response body in standard JSON format. |
etag |
The etag header shows the resource etag for the database resource retrieved. The etag has the same value as the _etag property in the response body. |
Date |
The date-time of the response operation. This date time format conforms to the RFC 1123 date time format expressed in Coordinated Universal Time. |
Custom Header |
Description |
x-ms-resource-quota |
For this operation, this header shows the allotted document size quota for the account. |
x-ms-resource-usage |
For this operation, this header shows the current document size consumed for the account. |
x-ms-request-charge |
This is the number of request units (RU) consumed by the operation. For more information about request units, see Manage DocumentDB capacity and performance. |
x-ms-activity-id |
This is the unique identifier for the operation. It is used for trouble-shooting purposes. |
Property |
Description |
id |
This is the unique name used to identify a document, i.e. no two documents can share the same id. The id must not exceed 255 characters. |
custom |
Any user-defined JSON. |
_rid |
This is a system generated property. The resource ID (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement and navigation of the document resource. |
_ts |
This is a system generated property. It specifies the last updated timestamp of the resource. The value is a timestamp. |
_self |
This is a system generated property. It is the unique addressable URI for the resource. |
_etag |
This is a system generated property that specifies the resource etag required for optimistic concurrency control. |
attachments |
This is a system generated property that specifies the addressable path for the attachments resource. |
The following table lists common status codes returned by this operation. For information related to error status codes, see HTTP Status Codes.
Code |
Description |
200 Ok |
The operation was successful. |
400 Bad Request |
The override set in the x-ms-consistency-level header is stronger than the one set during account creation. For example, if the consistency level is Session, the override cannot be Strong or Bounded. |
401 Unauthorized |
The Authorization or x-ms-date header is not set. 401 is also returned when the Authorization header is set to an invalid authorization token. For more information on authorization token, see Access Control on DocumentDB Resources. |
403 Forbidden |
The authorization token has expired. |
404 Not Found |
The document is no longer a resource, i.e. the document was deleted. |
HTTP/1.1 200 Ok
Transfer-Encoding: chunked
Content-Type: application/json
Server: Microsoft-HTTPAPI/2.0
x-ms-last-state-change-utc: Sat, 16 Apr 2015 17:59:42.904 GMT
etag: 00005c00-0000-0000-0000-53f178510000
x-ms-resource-quota: documentsSize=10475520;
x-ms-resource-usage: documentsSize=0;
x-ms-schemaversion: 1.1
x-ms-request-charge: 1
x-ms-indexing-directive: Default
x-ms-serviceversion: version=1.0.240.1
x-ms-activity-id: 7a1abb31-c538-42ae-b646-d8cd37678781
x-ms-gatewayversion: version=1.0.240.1
Date: Mon, 18 Apr 2015 07:39:22 GMT
{
"Title":"About St. Louis",
"Language":{
"id":"English"
},
"id":"ISBN0-8800-1599-1",
"_rid":"-yI8AKNuyAANAAAAAAAAAA==",
"_ts":1408333905,
"_self":"dbs\/-yI8AA==\/colls\/-yI8AKNuyAA=\/docs\/-yI8AKNuyAANAAAAAAAAAA==\/",
"_etag":"00005c00-0000-0000-0000-53f178510000",
"_attachments":"attachments\/"
}