Hi y'all, first of all, I am sorry if this question has been answered before or if this is a really nooby thing to ask. I'm quite new to Arduino and trying to integrate this into a project I am working on.
The problem I am running into is that I want to send a POST request to my web server to store stuff in my database. Sending this post request works perfectly, both from my laptop the development server is currently running on, as with my phone. When trying to do so with the Arduino, I receive a 400 bad request.
Apache logs show:
192.168.0.100 - - [14/Mar/2022:12:37:11 +0100] "POST /api/checkin/684759 HTTP/1.1" 400 325 "-" "Arduino/1.0"
192.168.0.102 - - [14/Mar/2022:12:43:13 +0100] "POST /api/checkin/6 HTTP/1.1" 200 - "-" "PostmanRuntime/7.29.0"
If I'm correct, this indicates data gets returned to the Arduino. The thing is, I have no clue on how to display this data. The code that is currently running is:
char server[] = "192.168.0.102";
IPAddress ip(192, 168, 0, 177);
//sending data
void Send_To_Webserver()
{
if (client.connect(server, 80)) {
Serial.println("connected");
Serial.println("POST api/checkin/684759");
client.println("POST /api/checkin/684759 HTTP/1.1");
client.println("Host: 192.168.0.102");
client.println("User-Agent: Arduino/1.0");
client.println("Connection: close");
} else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
delay(1000);
digitalWrite(led_green, LOW);
digitalWrite(led_red, LOW);
}
If any more information is needed, please let me know. All help is greatly appreciated!