-->
Page 1 of 1

406 & 400 errors

PostPosted: Fri Feb 06, 2015 4:30 pm
by geresy
Hi guys, I'm new here ... bought a few of these ESPs from ebay and I managed to get stuck creating a http request.
If I use postman to create the request it's all good, tried all kinds of combinations, added host

I'm using Software serial for arduino -> esp. Baud rate is 9600

Code: Select all  wifi.println("AT+CIPSTART=\"TCP\",\"192.168.1.100\",80");     
  Serial.println("AT+CIPSTART=\"TCP\",\"192.168.1.100\",80");

  if(wifi.find("Connected")) {
    Serial.println("Connected ...");
  }

  String data="POST /api/temp \r\n"
 "Content-Type: application/x-www-form-urlencoded\r\n"
 "&title=sometitle&type=temp&body=20\r\n\r\n";
   

  ready="AT+CIPSEND=";   //length
  ready+=data.length();
  sendData(ready);     
  Serial.println(data);
  wifi.println(data);

Re: 406 & 400 errors

PostPosted: Sat Feb 07, 2015 8:10 am
by geresy
Had to send the content-length ..
This worked for me.
Code: Select allString request="&title=sometitle&type=temp&body=20\r\n";
data="POST /api/temp HTTP/1.0\r\n";
data += "Host: myhost \r\n";
data += "Content-Length: ";
data += request.length();
data += "\r\n";
data += "Content-Type: application/x-www-form-urlencoded\r\n";
data += "\r\n";
data += String(request);
data += "\r\n";