Hii, I am facing a problem for sending GET request to my server using ethernet and UIPEthernet Library.
I have taken code reference from here
Here is my code:
#include <UIPEthernet.h>
EthernetClient client;
uint8_t mac[6] = {0x8B, 0xAA, 0xB5, 0xA2, 0x14, 0xB0};
String tagID = "1235AC";
String RTCtime2 = "2020-12-14%2020:24:20";
String GateNO = "gate2";
void setup() {
Serial.begin(115200);
char server[] = "http://mywebsite.000webhostapp.com";
String data = "?tagID=";
data += tagID;
data += "&RTCtimestamp=";
data += RTCtime2;
data += "&GateNO=";
data += GateNO;
if(Ethernet.begin(mac) == 0){
Serial.println("Failed to configure Ethernet using DHCP");
while(1);
}
if (client.connect(server,80)){
Serial.println("Connected to server");
client.println("GET /connect.php HTTP/1.1");
client.println("Host: mywebsite.000webhostapp.com");
client.println("Content-Type: multipart/form-data");//application/x-www-form-urlencoded//multipart/form-data
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.println(data);
client.println();
Serial.println(data.length());
Serial.println(data);
}else{
Serial.println("Connection to server failed");
}
}
void loop() {
while(client.connected()){
if(client.available()){
char c = client.read();
Serial.print(c);
}
}
}
In the output I get HTTP 1.1/ 200 OK
But nothing is updated in my database
Also, The content size is shown as "0"
When I tried sending the data using only Wi-Fi and ESP32, The database is updated.
What could be the reason?