It's 8000 lines.. but i can embed it in the example:
#include <ArduinoHttpClient.h>
#include <WiFi101.h>
#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
/////// WiFi Settings ///////
char ssid[] = SECRET_SSID;
char pass[] = SECRET_PASS;
char serverAddress[] = "192.168.0.3"; // server address
int port = 8080;
WiFiClient wifi;
HttpClient client = HttpClient(wifi, serverAddress, port);
int status = WL_IDLE_STATUS;
void setup() {
Serial.begin(9600);
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to Network named: ");
Serial.println(ssid); // print the network name (SSID);
// Connect to WPA/WPA2 network:
status = WiFi.begin(ssid, pass);
}
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
}
void loop() {
Serial.println("making GET request");
String get_text = "/cgi-bin/sms_send?text=";
String get_text2 = "Hallo";
String get_complete = get_text + get_text2;
client.get(get_complete);
// read the status code and body of the response
int statusCode = client.responseStatusCode();
String response = client.responseBody();
Serial.print("Status code: ");
Serial.println(statusCode);
Serial.print("Response: ");
Serial.println(response);
Serial.println("Wait five seconds");
delay(5000);
}
I can't imagine how the change you described could cause an error. I think it must be something else, a coincidence, making it look like that change caused the error.
Can you expand your example sketch to do the request both ways in turn, printing the string to serial monitor that is given to .get(), and post the text from serial monitor?
Because i had a unencoded value stored in my variable, not like i wrote in the example,
the error had nothing to do with the String operation. The response was a http 400 bad request.
My fault, i forgot the encoding and thought it was the String operation (You know, the C+ evil beast)
I think what you are saying is that the code you posted, that you said did not work, did in fact work. You assumed it would not work, but had not tested it? But you posted it here and asked the forum why it did not work.
The posted code here worked. But when the Variable get_text2 is filled with a String containing blanks, ä, ü etc. it does not. It's neccesary to encode the String before use it for a http method get.
I posted the explanation and the solution if somone later finds this post.
On my side, i tested the code within a large sketch and this issue came up and i had no idea why and that's why I allowed myself to consult the forum.
jfjlaros asked for a complete sketch thats why i pasted my code in the arduino example. Because i didn't know the type of error i posted accidentally a working sketch.
If i had known then, what i know now, i would not have asked the question...
Thanks again for your help
Ergo: For those who find this topic with the same issue : urlencode your http get / post.