1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| procedure TForm1.Button2Click(Sender: TObject);var
MyHTTPRequest: TFPHTTPClient;
MyURL: String;
Response: TStringList;
begin
MyURL := 'https://wxs.ign.fr/essentiels/alti/rest/elevation.json?lon=0.2367&lat=43.08&zonly=true';
Response := TStringList.Create;
Response.Clear;
MyHTTPRequest := TFPHTTPClient.Create(self);
MyHTTPRequest.AddHeader('User-Agent','Mozilla/5.0 (compatible; fpweb)');
MyHTTPRequest.AddHeader('Content-Type','application/json; charset=UTF-8');
MyHTTPRequest.AddHeader('Accept', 'application/json');
MyHTTPRequest.AllowRedirect := true;
try
MyHTTPRequest.get(MyURL, Response);
ShowMessage(Response.Text);
finally
FreeAndNil(MyHTTPRequest);
FreeAndNil(Response);
end; |
Partager