title: ESP32 Asynch Web Server POST method not working
body: <p>I'm having trouble getting the POST method to work with the ESP32 &amp; the Async Web Server. To be precise, the POST route is recognised but processing of the body fails.</p>
  <p>The ESP32 is a WROOM-32. The POST example is adapted from <a href="https://techtutorialsx.com/2017/12/09/esp32-arduino-asynchronous-http-webserver-simple-html/" rel="nofollow noreferrer">ESP32 Arduino async HTTP server: Serving HTML</a></p>
  <p>The web server and indeed the ESP32 appears to work in every other way I have tried. Although my example below doesn't show it, the GET method works just fine. The problem arises when I try to process the body of the POST request. I have put a comment in the code &quot;Code here is NOT execute&quot; to show what is not working. The simple form &quot;/testform.html&quot; is displayed, but when submitted, the header part of the POST handler shows that the content type is &quot;application/x-www-form-urlencoded&quot;, but nothing is returned to the Chrome browser and the print statements intended to show the body of the POST do not execute.</p>
  <p>The ESP32 code is as follows (I'm using the Arduino IDE):</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &quot;WiFi.h&quot;
  #include &quot;ESPAsyncWebServer.h&quot;
  #include &quot;SPIFFS.h&quot;
   
  const char* ssid = &quot;xxxxxx&quot;;      // Actual SSID &amp; Pw removed
  const char* password = &quot;xxxxxx&quot;;
  AsyncWebServer server(80);
   
  void setup() {
    Serial.begin(115200);
   
    WiFi.begin(ssid, password);
   
    while (WiFi.status() != WL_CONNECTED) {
      delay(1000);
      Serial.println(&quot;Connecting to WiFi..&quot;);
    }
  
    // Initialize SPIFFS
    if(!SPIFFS.begin(true)) {
      Serial.println(&quot;An Error has occurred while mounting SPIFFS&quot;);
      return;
    }
    Serial.println(WiFi.localIP());
  
    server.on(&quot;/testform.html&quot;, HTTP_GET, [](AsyncWebServerRequest *request) {
      request-&gt;send(SPIFFS, &quot;/testform.html&quot;, String(), false);
    });
   
    server.on(
      &quot;/my-handling-form-page&quot;,
      HTTP_POST,
      [](AsyncWebServerRequest * request) {
          // The following print statements work + removing them makes no difference
          // This is displayed on monitor &quot;Content type::application/x-www-form-urlencoded&quot;
          Serial.print(&quot;Content type::&quot;);
          Serial.println(request-&gt;contentType());
      },  // Route handling function
      
      NULL,
      [](AsyncWebServerRequest * request, uint8_t *data, size_t len, size_t index, size_t total) {
  
    // *** Code here is NOT executed *** 
      
    for (size_t i = 0; i &lt; len; i++) {
      Serial.write(data[i]);
    }
    Serial.println();
    request-&gt;send(200);
    });
  
    // Start server
    server.begin();
  }
  
  void notFound(AsyncWebServerRequest *request) {
    request-&gt;send(404, &quot;text/plain&quot;, &quot;My not found ***** &quot;);
  }
   
  void loop()`{
    
  }
  </code></pre>
  <p>The &quot;testform.htm&quot; web page, is pretty simple and displays as expected when requested by the browser</p>
  <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt; 
      &lt;b&gt;Test Form&lt;/b&gt;
    &lt;/head&gt;
  
    &lt;body&gt;
      &lt;form action=&quot;/my-handling-form-page&quot; method=&quot;post&quot;&gt;
        &lt;ul&gt;
          &lt;li&gt;
            &lt;label for=&quot;name&quot;&gt;Name:&lt;/label&gt;
            &lt;input type=&quot;text&quot; id=&quot;name&quot; name=&quot;user_name&quot;&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
         
        &lt;li class=&quot;button&quot;&gt;
          &lt;button type=&quot;submit&quot;&gt;Send your message&lt;/button&gt;
        &lt;/li&gt;
      &lt;/form&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>I hope someone can either find the obvious boo-boo or give me a clue to what I might try next.</p>