http请求心知天气400 The plain HTTP request was sent to HTTPS port解决方案

问题说明

在调用http.begin(client, "https://api.seniverse.com/v3/weather/now.json?key=your_private_key&location=beijing&language=zh-Hans&unit=c")函数时报错

<html>
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
<hr><center>nginx</center>
</body>
</html>

解决方案

调用http.begin(client, host, 80, urlDate);
如下

String urlDate = "/v3/weather/daily.json?key="+my_private_key+"&location="+City+"&language=zh-Hans&unit=c";
http.begin(client, "api.seniverse.com",80,urlDate);

猜你喜欢

转载自blog.csdn.net/qq_39592312/article/details/107969233