title: C# Error 401 - Invalid username or password
body: <p>I'm trying to make requests to an API.
  When I made the request using postman, it works. But in c#, it doesn't, it returns Error 401.
  I checked and login and password are right.
  Can anyone help me?</p>
  
  <hr>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>public JsonResult Test()
  {
      var document = new HtmlAgilityPack.HtmlDocument();
  
      var password = CalculateMD5Hash("******");
  
      var httpRequest =(HttpWebRequest)WebRequest.Create(string.Format("https://api.akna.com.br/emkt/int/integracao.php?User={0}&amp;Pass={1}&amp;XML={2}",
      "mail@mail.com",
       password,
      @"&lt;main&gt;
      &lt;emkt trans='19.10'&gt;
      &lt;datainicial&gt;2016-07-01 10:00:00&lt;/datainicial&gt;
      &lt;datafinal&gt;2016-07-02 10:00:00&lt;/datafinal&gt;
      &lt;/emkt&gt;
      &lt;/main&gt;"));
  
      httpRequest.Method = "POST";
      httpRequest.ContentType = "application/x-www-form-urlencoded";
  
      try
      {
      var httpWebResponse = (HttpWebResponse)httpRequest.GetResponse();
  
      var responseStream = httpWebResponse.GetResponseStream();
  
      if (responseStream != null)
      {
       var sr = new StreamReader(responseStream, Encoding.Default);
       document.LoadHtml(sr.ReadToEnd());
     }
  
     return Json(new { StatusCode = 200 }, JsonRequestBehavior.AllowGet);
     }
    catch (Exception ex)
    {
    return Json(new { StatusCode = 500, Erro = ex.Message }, JsonRequestBehavior.AllowGet);
   }
   }
  </code></pre>