I just took MyCouch the .Net client for CouchDb for a spin with Cloudant. My findings? It was super easy to get started with a multi tenant account at Cloudant. You could probably do it under 5 min. Let me take you through some easy steps and show you how-to do it.

Setting things up

First, I Just went over to Cloudant’s site and registered for an account and then created a database in the dashboard.


Second, in the dashboard, after creating the database, I generated an API-key for use with my test app.

Finally, I configured the API-key's permissions for the database.

Bam! That’s it. If you followed this, your all set and ready to go and now have a hosted NoSQL data storage solution available to you over HTTP.

Code away

Lets look at a quick sample of how to currently connect (simplified API is coming) to Cloudant and make use of the hosted database. The API-key created earlier is used using basic authentication over https.

The first thing you need to do, is to install the NuGet package:

PM> install-package mycouch

The next step is to get connected (read more in the docs):

//If you have chars not allowed in the URL
//wrap in Uri.EscapeUriString, e.g.
var credentials = string.Format("{0}:{1}",

var url = string.Format(

There are some alternative ways, like a MyCouchUriBuilder that you can read about in the documentation.

Now, lets continue and connect and to a simple POST and GET using plain JSON.

using (var client = new Client(url))
  var posted = client
    .PostAsync("{\"msg\": \"MyCouch says hello to Cloudant!\"}")

  var requested = client


Outputs this to the console:

  "msg":"MyCouch says hello to Cloudant!"

The same using entities, would look like this:

using (var client = new Client(url))
  var msg = new Message {
    Text = "MyCouch says hello to Cloudant!"

  var posted = client

  //If successful, msg.MessageId and msg.MessageRev
  //now has correct values, and we can use those.
  var requested = client


public class Message
  public string MessageId { get; set; }
  public string MessageRev { get; set; }
  public string Text { get; set; } 

Outputs this to the console:

"MyCouch says hello to Cloudant!"

By default, the Entities API comes with some conventions, like mapping the MessageId to _id. You can read more about it in the documentation.

Depending on what kind of request you perform the response will look a bit different, but there are some basic members providing you with generated _id & _rev etc. as well as basic HTTP response status etc, which looks something like this:


The future

I just released v0.11.0 of MyCouch, and are now planning on starting on some Cloudant specific features, distributed as a separate NuGet package. More on this will follow. But in short, I hope MyCouch can be made best buddy with Cloudant.



CouchDB & Cloudant, Data storage, Development
, , ,

Join the conversation! 4 Comments

  1. […] MyCouch says hello to Cloudant […]

  2. Reblogged this on Daniel Wertheim and commented:

    Some writings on my “new blog”. Will re-blog some of them here for a while.

  3. Hi Daniel,

    I tried all the above steps. I can connect to Cloudant, but when I try to Post or Read something, I get the “Status=WaitingForActivation”.

    What does this status mean?



    • Sorry for the late reply. I would contact Cloudant in these cases. I’m just guessing it means that your account or something has not been activated.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 33 other followers

%d bloggers like this: