O'Reilly logo

Learning Azure DocumentDB by Riccardo Becker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding a document

The following snippets show how to create a document in a certain collection:

//get signature based on masterkey, collection resource id and resource type documents (docs) signature = GetSignature(masterKey, collectionRid, "docs", "POST"); client.DefaultRequestHeaders.Remove("authorization"); client.DefaultRequestHeaders.Add("authorization", signature); string json = JsonConvert.SerializeObject(new { id = Guid.NewGuid().ToString(), test = "hello DocumentDB, created via REST API!" }); HttpContent contentPost = new StringContent(json); //add payload to body //do the post against the REST API and create the document var postResponse = client.PostAsync(new Uri(baseUri, string.Format("dbs/{0}/colls/{1}/docs", deviceHubDb.ResourceId, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required