Chat freely about anything...

User avatar
By LimeHaze
#30912 Hello,

I came across a problem when i try to send data using more than one "/" on my GET command url link.
I am sending serial data to the esp8266 via an Arduino.

EX:

Not working:
Code: Select allString GET = "GET  /~test/update.php?a=";


Working:
Code: Select allString GET = "GET /update?key=[MY_API_KEY]&field1="


Send data fonction:
Code: Select allvoid sendData(int d) {
  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += IP;
  cmd += "\",80";
  Serial.println(cmd);
  delay(2000);
  if(Serial.find("Error")){
    return;
  }
  cmd = GET;
  cmd += String(d);
  cmd += "\r\n";
  Serial.print("AT+CIPSEND=");
  Serial.println(cmd.length());
  if(Serial.find(">")){
    Serial.print(cmd);
  }else{
    Serial.println("AT+CIPCLOSE");
  }
}


Anyone know how to fix this?

LimeHaze
User avatar
By Barnabybear
#30932 Hi, this part of a string below has 2 / and works ok . "POST /update HTTP/1.1\n".
Code: Select all void loop() {
    if (client.connect(server,80)) {  // connects to thingspeak & sends the value of (pir)
        String postStr = apiKey;
               postStr +="&field1=";
               postStr += String(pir);
               postStr += "\r\n\r\n";
         client.print("POST /update HTTP/1.1\n");
         client.print("Host: api.thingspeak.com\n");
         client.print("Connection: close\n");
         client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
         client.print("Content-Type: application/x-www-form-urlencoded\n");
         client.print("Content-Length: ");
         client.print(postStr.length());
         client.print("\n\n");
         client.print(postStr);
      }

I'm not sure that the "/" is the problem.
Can you post what it is your trying to do & with what exactly goes wrong.
User avatar
By forlotto
#30993 Ahhh between GET and / indeed good eye wouldn't hurt to give it a run the one that works does not have the extra space as well very possible.