title: Authentication Details Not Provided REST API POST Request
body: <p>I'm posting to an API server and I'm getting the following reply:</p>
  
  <pre><code>Server Response: {"detail":"Authentication credentials were not provided."}
  </code></pre>
  
  <p>I'm writing the requests in Java and I'm not sure exactly why it's saying credentials were not provided.</p>
  
  <p>Here is a snippet of my code:</p>
  
  <pre><code> hconn.setRequestProperty("Content-Type", "application/json");
   hconn.setRequestProperty( "Accept", "application/json" );
   if( urlconn instanceof HttpsURLConnection )
   {
      String encoded = new String(Base64.getEncoder().encode( ( username + ":" + password).getBytes()));
      String auth = "Basic " + encoded;
      urlconn.setRequestProperty("Encoded Authorization", auth );
  
   }
  </code></pre>
  
  <p>Where <code>hconn</code> is of type <code>HttpURLConnection</code></p>
  
  <p>This is the only relvant snippet that you guys need. Are there properties i'm missing to set here?</p>
  
  <p>I know the server response is from a Django framework but the documentation is not clear on spotting what IS required to prevent this.</p>
  
  <p>Any help appreciated.</p>