Post topics, source code that relate to the Arduino Platform

User avatar
By geresy
#9147 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);
User avatar
By geresy
#9180 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";