0

when I try to send http get request I get error 404

AT+CIPMTX=1

OK
AT+CIPSTART=4,"TCP","alirezaabrhshami.ir",80
4,CONNECT
OK
AT⸮⸮R5U9⸮⸮b⸮⸮j
OK
>
Recv 47 qytes
SEND OK
+IPD,4,223;HTTP/1.1 404 Not Found
Cache-Contsol: public, max-age=0:a1n CeK⸮

this is my code:

#include <SoftwareSerial.h>

const byte rxPin = 2;
const byte txPin = 3;
SoftwareSerial ESP8266 (rxPin, txPin);

unsigned long lastTimeMillis = 0;

void setup() {
  Serial.begin(9600);   
  ESP8266.begin(115200);
  delay(2000);
}

void printResponse() {
  while (ESP8266.available()) {
    Serial.println(ESP8266.readStringUntil('\n')); 
  }
}

void loop() {

  if (millis() - lastTimeMillis > 30000) {
    lastTimeMillis = millis();

    ESP8266.println("AT+CIPMUX=1");
delay(1000);
printResponse();

ESP8266.println("AT+CIPSTART=4,\"TCP\",\"alirezaabrishami.ir\",80");
delay(1000);
printResponse();

String cmd = "GET /greencare/login.php?product_id=123456 ";
ESP8266.println("AT+CIPSEND=4," + String(cmd.length() + 4));
delay(1000);

ESP8266.println(cmd);
delay(1000);
ESP8266.println(""); 
  }

  if (ESP8266.available()) {
    Serial.write(ESP8266.read());
  }

}
2

1 Answer 1

1

your HTTP request is incomplete. it should be

String cmd = "GET /greencare/login.php?product_id=123456 HTTP/1.1\r\nHost:alirezaabrishami.ir\r\n\r\n"

if the wen server host has more hostnames for the same IP address, the Host header is used on HTTP server to direct the request to the right web application

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.