I am surely missing something, but what ?
This is my code
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <HTTPClient.h>
String tempo="http://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter=2021-02-17&TypeAlerte=TEMPO";
http.begin(tempo.c_str());
http.GET();
TERM.println(http.getString());
http.end();
If I put directly the string tempo in a brouwser, I get the answer
{"JourJ1":{"Tempo":"TEMPO_BLEU"},"JourJ":{"Tempo":"TEMPO_BLEU"}}
But in my arduino script on a ESP-Wroom-32
I get
error code 1001
Can you help me ?
Thanks
Take a look at https://randomnerdtutorials.com/esp32-http-get-post-arduino/
Is that the entirety of your code? To get to the internet over WiFi you need to connect to your router.
Thanks for the answer, but
I have seen these pages, but it was not sufficient to help me. This is why I Ask on this forum for specific help.
Of course, there is additional for the connection to internet through wifi. I could test that I am well connected and that the problem is not in the connection.
If you think you have a solution, it is very easy to test it on your side, as the api is open to all. As I said, everything works well if you just put the http sequence in a browser.
Hi.
We’ve tried multiple examples and everything we could think of.
However, it looks like the server has some sort of configuration or firewall software that blocks all connections from “unknown” devices (like IoT) devices. If you access it with a normal web browser, it replies. However, it denies all connections from other devices.
Even with a different code that we’ve trying that makes HTTPS requests, all connections are blocked:
[HTTPS] begin...
[HTTPS] GET...
[HTTPS] GET... failed, error: connection refused
So, it seems that you’ll have to use another service to request weather data. For example, you can use OpenWeatherMap.
I hope this helps.
Regards,
Sara
Thanks a lot, Sara.
I see that you have really addressed the problem and not just send a standard reply.
I have made some progress on my side, with the help of my son.
The first step was to be able to make the request from a standard unix machine in command line (here a mac) .
One of the problem seems that the server does not accept any kind of user agent. This has been solved by specifying the user agent. Now at least the following commands works
curl -A "Mozilla/5.0 Gecko/20100101" "https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter=2021-02-15&TypeAlerte=TEMPO"
with the correct answer
{“JourJ1”:{“Tempo”:”TEMPO_BLANC”},”JourJ”:{“Tempo”:”TEMPO_BLANC”}}
I have thus updated the code as follows
String tempo="https://particulier.edf.fr/bin/edf_rc/servlets/ejptemponew?Date_a_remonter=2021-02-17&TypeAlerte=TEMPO"; String user_agent = "Mozilla/5.0 Gecko/20100101"; TERM.println(""); TERM.println(tempo); http.begin(tempo,nullptr); http.setUserAgent(user_agent); http.GET(); TERM.println(http.getString()); http.end();
But this still not works.
Any additional help is very welcome as it is impossible to get this information from another server.
Hi.
Do you get the same error even when setting the user agent?
Does that website allow you to set up an account to use an API or something? (I can’t read french, and even with translater, it isn’t easy to understand).
Regards,
Sara
Hi.
I’m not sure, but I think that even though you set the user agent, it knows that it is not an actual web browser making the request.
I’m sorry, but I don’t have any more ideas on how to workaraound this issue.
Regards,
Sara
I had a similar problem here at work (NOT using ESP32) where the server was only sending the server certificate instead of the entire certificate chain. It would work fine in a browser as browsers support the “certificate discovery” feature which will ask the server for the intermediate and root certificates.
You could try adding the certificate chain (Download the chain from your browser) as a string and specifying that in your http.begin (The second parameter is the Certificate Authority Certificate – CACert).
Thanks Steve, but I have also tried that.
The first attempt was putting the NULL pointer as second argument as in the code above , but to be sure, I did it also with the certificate chain downloaded from the browser.
Thanks Steve, but I have also tried that.
The first attempt was putting the NULL pointer as second argument as in the code above , but to be sure, I did it also with the certificate chain downloaded from the browser.
Just looked at the certificate again and it’s using TLS1.2. Perhaps try the WiFiClientSecure library?
Hi again.
Thanks for trying to help, Steve.
I have tried previously with this example with the right certificate, and the connection was refused:
https://github.com/espressif/arduino-esp32/blob/master/libraries/HTTPClient/examples/BasicHttpsClient/BasicHttpsClient.ino
It uses WiFiClientSecure. So, no luck with this, too :/
Regards,
Sara