title: Esp8266 HttpClient Post
body: <p>I am trying to create a call to a server on the web making use of HttpPost but i keep getting a response of -1 (error: connection refused)</p>
  
  <p>I am able to make an HTTPGet request but my httpPost fails. If i take that same data that i am trying to post and put that into Fiddler and do a post from there i get a 200 OK.</p>
  
  <p>Below is the code that i am trying to execute :</p>
  
  <pre><code>void PostData() {
    String data = "mailSend=1&amp;new=1&amp;rec=Gupta+Classic&amp;topic=ddd&amp;reply=ddd&amp;fbSig=bE9";
    String url = "https://www.shippingmanager.dk/sh/mailbox.php";
    HTTPClient http;
    http.setReuse(true);
    http.begin(url);
    http.addHeader("Host", "www.shippingmanager.dk");
    http.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0");
    http.addHeader("Accept-Language", " en-US,en;q=0.5");
    http.addHeader("Accept-Encoding", " gzip, deflate, br");
    http.addHeader("Content-Type", " application/x-www-form-urlencoded; charset=UTF-8");
    http.addHeader("X-Requested-With", " XMLHttpRequest");
    http.addHeader("Referer", " https://www.shippingmanager.dk/sh/?fb_source=shippingmanager.dk");
    http.addHeader("Connection", "keep-alive");
    http.addHeader("Pragma", " no-cache");
    http.addHeader("Cache-Control", " no-cache");
  
    int result = http.POST(data);
    http.writeToStream(&amp;Serial);
    http.end();
  
  }
  </code></pre>
  
  <p>this is the raw text that i post in Fiddler to do the post :</p>
  
  <pre><code>POST https://www.shippingmanager.dk/sh/mailbox.php HTTP/1.1
  Host: www.shippingmanager.dk
  User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0 
  Accept: */* 
  Accept-Language: en-US,en;q=0.5 
  Accept-Encoding: gzip, deflate, br 
  Content-Type: application/x-www-form-urlencoded; charset=UTF-8 
  X-Requested-With: XMLHttpRequest 
  Referer: https://www.shippingmanager.dk/sh/?fb_source=shippingmanager.dk  
  Connection: keep-alive 
  Pragma: no-cache 
  Cache-Control: no-cache
  
  mailSend=1&amp;new=1&amp;rec=Gupta+Classic&amp;topic=ddd&amp;reply=ddd&amp;fbSig=J9
  </code></pre>
  
  <p>Please can someone point me to my problem.</p>
  
  <p>I also tried the code in this link and that also failed me :-(</p>
  
  <p><a href="http://www.esp8266.com/viewtopic.php?f=29&amp;t=14054" rel="nofollow noreferrer">http://www.esp8266.com/viewtopic.php?f=29&amp;t=14054</a></p>