I am not knowledgeable in HTTP protocol programming, hope someone can offer some expertise here. My ESP32 project’s been successfully using GET to download text from the website aviationweather.gov… up to a few days ago. The site changed the protocol and now I am unable to figure out how to download data from it. The site's API specifies:
Curl
curl -X 'GET'
'https://aviationweather.gov/api/data/metar?ids=KSJC'
-H 'accept: text/plain'
Request URL https://aviationweather.gov/api/data/metar?ids=KSJC
In my sketch, I am sending the request: GET https://www.aviationweather.gov/api/data/metar?ids=KSFO HTTP/1.1
In return, I am getting a 400 error and the following:
Header:
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Date: Fri, 20 Oct 2023 04:21:15 GMT
Content-Length: 334
Body:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Hostname</h2>
<hr><p>HTTP Error 400. The request hostname is invalid.</p>
</BODY></HTML>