I think your question is more for the genera CouchDbl users group, but have you tried looking at one of the .NET libraries out there? I use LoveSeat ( https://github.com/soitgoes/LoveSeat) which works for my purposes. Even if you don't want to use that library, you can check out the authentication code in the CouchRequest.cs file to get a template to work from.
Nick North On 9 August 2012 16:38, Steven Kitterman <[email protected]> wrote: > Hi guys. > > I am trying to replicate a database using .NET classes (httpWebRequest) > instead > of > curl. Unfortunately, the cURL works, but the (assumably) same syntax in > .NET > fails > 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\", > \"create_target\":true, > \"user_ctx\": { \"roles\": [\"_admin\"] } }"; > > using (var writer = new > StreamWriter(request.GetRequestStream())) > { > writer.Write(json); > writer.Close(); > } > > 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. > >
