Web Page Request Not Working Correctly

MrGadget
Posts: 5
Joined: Sat Apr 02, 2022 11:54 pm

Web Page Request Not Working Correctly

Postby MrGadget » Wed Oct 19, 2022 11:47 pm

I have an EmonCMS running on my Raspberry Pi on my local network which collects data from various sensors based on the ESP processors. The EmonCMS allows me to store and display the data in many ways.

I can retrieve data for id=1 using a web browser:
  1. http://192.168.11.235/feed/value.json?id=1
And I get the results for id 1.

Or, I can retrieve data for id=2 using a web browser:
  1. http://192.168.11.235/feed/value.json?id=2
And I get the results for id 2.

However using the ESP32 only when id=1 does it give me correct data (when I un-comment line 4 below)

But, if I un-comment line 5 (line 4 is commented out) then I get a 406 error:
{"success":false,"message":"406 Not Acceptable. Route not found"}

Now this is just my example, I have id's that go up to 46 and they all work in a web browser but only id=1 works with the code below running on my ESP.

Does anyone know what my problem might be?


  1. void loop() {
  2.    if ((WiFi.status() == WL_CONNECTED)) { //Check the current connection status
  3.      HTTPClient http;
  4.      //http.begin("http://192.168.11.235/feed/value.json?id=1");   // THIS ONE WORKS
  5.      //http.begin("http://192.168.11.235/feed/value.json?id=2");     // THIS ONE FAILS
  6.      int httpCode = http.GET();                                    //  get 406 Not Acceptable. Route not found"  
  7.      if (httpCode > 0) { //Check for the returning code
  8.          String payload = http.getString();
  9.         Serial.println(httpCode);         // 200 which is for OK response
  10.         Serial.println(payload);            // data
  11.       }
  12.      else {
  13.       Serial.println("Error on HTTP request");
  14.     }
  15.      http.end(); //Free the resources
  16.   }
  17.    delay(10000);
  18.  }

Who is online

Users browsing this forum: No registered users and 80 guests