title: Getting 400 exception in HttpWebRequest Call
body: <p>I am using Postman to get the response from rest end point, and if I pass wrong data I am getting 400 exception which is very correct as per the logic.</p>
  
  <p><a href="https://i.stack.imgur.com/RRA5H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RRA5H.png" alt="enter image description here"></a></p>
  
  <p>But if I try to call the same web request from C# code(with same wrong parameter), I am getting exception but not the same as I am getting in Postman tool.</p>
  
  <p><a href="https://i.stack.imgur.com/3S3FK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3S3FK.png" alt="enter image description here"></a></p>
  
  <pre><code>            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
              var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://apiurl");
              httpWebRequest.ContentType = "application/json";
              httpWebRequest.Headers.Add("Authorization", "Bearer " + token);
              httpWebRequest.Method = "POST";
              httpWebRequest.UserAgent = ".Net application";
  
              using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
              {
                   string json = JsonConvert.SerializeObject(obj);//obj is parameter
  
                   streamWriter.Write(json);
              }
  
              try
              {
                  HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                  using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                  {
                      var result = streamReader.ReadToEnd();
                  }
              }
              catch (WebException e)
              {
  
              }
  </code></pre>
  
  <p>Can I know why I am getting errors differently from postman and C# code</p>
  
  <p>Regards
  Anand</p>