title: reproduce successfull curl request in Arduino ESP8266
body: <p>I am a noob with the ESP8266 and Arduino IDE/code.</p>
  
  <p>I have a IR sensor connected to an ESP-07 and have code that successfully turns on an LED when motion is detected.</p>
  
  <p>I am trying to send a POST request to a raspberry pi running Webiopi to turn on a relay that is connected to the RPi.</p>
  
  <p>I have successfully run a curl request on the RPi which turns on GPIO pin #11 and activates the relay tied to that pin:
  <code>curl -v -X POST -u username:password http://192.168.2.10:8000/GPIO/11/value/0</code></p>
  
  <p>Server response is:</p>
  
  <pre><code>    * About to connect() to 192.168.2.10 port 8000 (#0)
      *   Trying 192.168.2.10...
      * connected
      * Connected to 192.168.2.10 (192.168.2.10) port 8000 (#0)
      * Server auth using Basic with user 'webiopi'
      &gt; POST /GPIO/11/value/1 HTTP/1.1
      &gt; Authorization: Basic **a key was provided by the server**
      &gt; User-Agent: curl/7.26.0
      &gt; Host: 192.168.2.201:8000
      &gt; Accept: */
      &gt; 
      * additional stuff not fine transfer.c:1037: 0 0
      * HTTP 1.0, assume close after body
      &lt; HTTP/1.0 200 OK
      &lt; Server: WebIOPi/0.7.1/Python3.2
      &lt; Date: Fri, 14 Jul 2017 01:27:05 GMT
      &lt; Cache-Control: no-cache
      &lt; Content-Type: text/plain
      &lt; Content-Length: 1
      &lt; 
      * Closing connection #0
  </code></pre>
  
  <p>I need to replicate this curl request on my ESP-07 using Arduino code.</p>
  
  <p>I have tried this code, but the relay doesn't turn on and no output from the Serial Monitor window comes through when the POST is submitted.</p>
  
  <pre><code>char server[] = "192.168.2.10"
  if (client.connect(server, 8000)) {
    Serial.println("Connected to server");
    // Make a HTTP request
    client.println("Authorization: Basic **I put the key generated from the curl call here**");
    client.println("Content-Type: application/x-www-form-urlencoded");
    client.println("Content-Length: 35");
    client.println("username=username&amp;password=password");
    client.println("User-Agent: curl/7.26.0");
    client.println("Host: 192.168.2.10:8000");
    client.println("POST /GPIO/11/value/0 HTTP/1.1");
    client.println("Accept: */*");
    client.println();
    delay(1000);
    Serial.println();
    Serial.println("disconnecting");
    Serial.println("==============");
    Serial.println();
    // if there are incoming bytes available
    // from the server, read them and print them:
    while (client.available()) {
      char c = client.read();
      Serial.print(c);
      }
    client.stop(); //stop client
    }
  </code></pre>
  
  <p>My apologies in advance if this request is too cryptic, but this is my first time posting on such a forum.</p>
  
  <p>Many thanks in advance...:-)</p>
  
  <p>@Cagdas, @Defozo, thx for your responses...
  This is what tried, but the code did not turn on the LED.</p>
  
  <pre><code>HTTPClient http;
  http.begin("http://192.168.2.10:8000/");
  http.addHeader("User-Agent", "curl/7.26.0"); 
  http.setAuthorization("username", "password");
  auto httpCode = http.POST("/GPIO/11/value/0");
  http.end();
  </code></pre>
  
  <p>@cagdas So I tried this next, still LED does not turn on</p>
  
  <pre><code>HTTPClient http;
  http.begin("http://192.168.2.10:8000/");
  http.addHeader("User-Agent", "curl/7.26.0"); 
  http.POST("username=username&amp;password=password");
  http.POST("/GPIO/11/value/0");
  http.end();
  </code></pre>
  
  <p>and just to reiterate, this was the curl call I was trying to replicate:</p>
  
  <pre><code>curl -v -X POST -u username:password http://192.168.2.10:8000/GPIO/11/value/0
  </code></pre>