couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Kitterman <>
Subject Unauthorized to access or create database--replication
Date Thu, 09 Aug 2012 15:38:49 GMT
Hi guys.

I am trying to replicate a database using .NET classes (httpWebRequest) instead 
curl. Unfortunately, the cURL works, but the (assumably) same syntax in .NET 
with a 404 "Unauthorized to access or create database" error. Below is my code. 

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("sourceURL");
            request.Method = "POST";
            request.ContentType = "application/json";

            long ticks = DateTime.UtcNow.Ticks;

            string json = "{ \"_id\":\"database_replicate" + ticks + "\", 
 \"source\":\"sourceURL/database\", \"target\":\"database\",   
 \"user_ctx\": { \"roles\": [\"_admin\"] } }";

            using (var writer = new StreamWriter(request.GetRequestStream()))

Then it fails right here, on the response:

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

I am replicating to and from localhost. I tried passing in our credentials 
(username and password), as request.credentials, but that didn't work either. 
Currently the credentials are being passed in the urls.

View raw message