ESP32 using HTTPClient library to call API
Posted: Tue Oct 23, 2018 5:35 pm
Hi, I'm having some problem, that maybe is really easy, I hope you can help me.
I'm using ESP32 and the library HTTPClient to call an API, like that.
When I run the get through the browser I get my normal database data, but by esp32 I have that answer below. I would like to know how to receive the normal data because as it seems to me, the function that is in my code is not calling API.
Just to clarify, I received this data when I use the browser.
I'm using ESP32 and the library HTTPClient to call an API, like that.
Code: Select all
HTTPClient http;
http.begin("http://130.101.93.116/resource/comanda");
http.addHeader("Content-Type", "application/x-www-form-urlencoded"); //Specify content-type header
int httpResponseCode = http.GET();
if(httpResponseCode>0){
String response = http.getString(); //Get the response to the request
Serial.print("httpResponseCode: "); //Print return code
Serial.println(httpResponseCode);
Serial.println(response); //Print request answer
}else{
Serial.print("Error on sending GET: ");
Serial.println(http.errorToString(httpResponseCode));
}
http.end();
Code: Select all
httpResponseCode: 200
<html>
<head>
<meta http-equiv='refresh' content='1; url=http://130.101.93.116/resource/comanda&arubalp=298629fd-4805-4e2c-bd14-9b616ceb85'>
</head>
</html>