title: 400 vs 401 http responses : which one is evaluated/returned first?
body: <p>I have been trying to make a post request with C# using Webclient. I was getting 400 bad request.When I adjusted the headers, and added authorization to it,I started getting 401 authorization error.Now i commented out the authorization, 400 bad request is back. So my question is: when it was returning 400, does it mean the server authenticated me and that something might be wrong with my json or can 400 be returned even before authentication is done? Below is my code.</p>
  <pre><code>    public static string Post(string json, string encoded){
       try{
            string url = &quot;https://blah/rest/api/blah&quot;;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            var client = new WebClient();
            client.Encoding = Encoding.UTF8;
            IWebProxy wp = WebRequest.DefaultWebProxy;
            wp.Credentials = CredentialCache.DefaultCredentials;
            client.Proxy = wp;
            //client.Headers[HttpRequestHeader.Authorization] = &quot;Basic &quot; + encoded;
            client.Headers[HttpRequestHeader.ContentType] = &quot;application/json&quot;;
            client.Headers[HttpRequestHeader.Accept] = &quot;application/json&quot;;
            var response = client.UploadString(url, &quot;POST&quot;,json);
            return response
          }
           catch(Exception e){
              return e
          }
  
       
  }
  </code></pre>