I have this code below code to create a database in couchDB:
private async void DatabaseCreate()
{
if (!await DatabaseExist())
{
var contents = new StringContent("", Encoding.UTF8, "text/plain");
this.uri = "http://USER:PASSWORD@localhost:5984/item_sn";
var response = await client.PutAsync(this.uri, contents); //set the contents to null but same response.
Console.WriteLine(response.Content.ReadAsStrifngAsync().Result);
}
}
My problem is that it is giving me a response with StatusCode:401, saying "Unauthorized". I tried curling it in the terminal and it gives me a successful response. Is there some preconditions I need to set for the httpclient? Or am I using the wrong method. I know there are some third party package for couchDB but for my case I just want to use C#'s httpclient.
Thanks in advance
curl command:
curl -X PUT http://USER:PASSWORD@localhost:5984/item_sn