What’s the simplest way to call Http GET url using Delphi?

Calling a RESTful web service using Indy is pretty straight forward.

Add IdHTTP to your uses clause. Remember that IdHTTP needs the “HTTP://” prefix on your URLs.

function GetURLAsString(const aURL: string): string;
var
  lHTTP: TIdHTTP;
begin
  lHTTP := TIdHTTP.Create;
  try
    Result := lHTTP.Get(aURL);
  finally
    lHTTP.Free;
  end;
end;

Leave a Comment