title: How to delete a RavenDB database with Raven.Client.Lightweight
body: <p>I have implemented what I believe to the proper way to delete a database (raven running as a service), based on the 1.2 Raven Studio's way of doing it and porting the code to a windows console. </p>
  
  <pre><code>static class Program
  {    
      static void Main(string[] args)
      {
          try
          {
              using (var store = new DocumentStore { ConnectionStringName = "RavenDB" }.Initialize())
              {
  
                  var metadata = new RavenJObject();
  
                  var factory = store.JsonRequestFactory;
  
                  const string url = "http://localhost:8080/admin/databases/raven-products?hard-delete=true";
  
                  var credentials = CredentialCache.DefaultCredentials;
  
                  var convention = new DocumentConvention();
  
                  var requestParams = new CreateHttpJsonRequestParams(store.DatabaseCommands, url, "DELETE", metadata, credentials, convention);
  
                  var request = factory.CreateHttpJsonRequest(requestParams);
  
                  request.ExecuteRequest();
  
              }
  
          }
          catch (Exception exception)
          {
              Console.WriteLine(exception);
          }
  
          Console.WriteLine("Press any key..");
          Console.ReadKey();
  
      }
  
  }
  </code></pre>
  
  <p>When this code is executed , the following exception is raised.</p>
  
  <blockquote>
    <p>System.Net.WebException: The remote server returned an error: (401) Unauthorized.
      at System.Net.HttpWebRequest.GetResponse()
      at Raven.Client.Connection.HttpJsonRequest.ReadJsonInternal(Func`1 getResponse) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\HttpJsonRequest.cs:line 297
      at Raven.Client.Connection.HttpJsonRequest.ReadResponseJson() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\HttpJsonRequest.cs:line 218
      at Raven.Client.Connection.HttpJsonRequest.ExecuteRequest() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\HttpJsonRequest.cs:line 161
      at Com.BuyEfficient.Raven.Service.Program.Main(String[] args) in c:\code\buyefficient_mvc\Com.BuyEfficient\Com.BuyEfficient.Raven
    .Service\Program.cs:line 39</p>
  </blockquote>
  
  <p>My question is this "How do I correctly set up the credentials so that the console app is authenticated"?</p>
  
  <p>Thank you,
  Stephen </p>
  
  <p><strong>UPDATE1</strong>
   Code updated to reflect accepted answer. </p>