Web Page Request Not Working Correctly
Posted: 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:
And I get the results for id 1.
Or, I can retrieve data for id=2 using a web browser:
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?
I can retrieve data for id=1 using a web browser:
- http://192.168.11.235/feed/value.json?id=1
Or, I can retrieve data for id=2 using a web browser:
- http://192.168.11.235/feed/value.json?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?
- void loop() {
- if ((WiFi.status() == WL_CONNECTED)) { //Check the current connection status
- HTTPClient http;
- //http.begin("http://192.168.11.235/feed/value.json?id=1"); // THIS ONE WORKS
- //http.begin("http://192.168.11.235/feed/value.json?id=2"); // THIS ONE FAILS
- int httpCode = http.GET(); // get 406 Not Acceptable. Route not found"
- if (httpCode > 0) { //Check for the returning code
- String payload = http.getString();
- Serial.println(httpCode); // 200 which is for OK response
- Serial.println(payload); // data
- }
- else {
- Serial.println("Error on HTTP request");
- }
- http.end(); //Free the resources
- }
- delay(10000);
- }