Arduino ESP8266: Http GET with dynamic parameters

  arduino, arduino-esp8266, c++, esp8266

I am new to Arduino and I am trying to send a GET request from an ESP8266 using the Http GET method
but I am getting an error 400 http code in return.

If i added the parameter manually on the URL string, I can get successful results, but when I dynamically pass the parameter in the URL string that is where I get the error 400. below is how I do it.

  HTTPClient http;
  String assignedStatChange = "0";
  String url = "http://example.com/api/send-device-data/"+userID;
  Serial.print("Sending Request:");
  Serial.println(url);
  http.begin(url);
  int httpCode = http.GET();
  Serial.print("HTTP code:");
  Serial.println(httpCode);

Appreciate any help. Thank you!

Source: Windows Questions C++

LEAVE A COMMENT