I am trying to download a file to a string:
function FetchUrl(const url: string): string;
var
 idhttp : TIdHTTP;
begin
  idhttp := TIdHTTP.Create(nil);
  try
    Result := idhttp.Get(url);
  finally
    idhttp.Free;
  end;
end;
What is wrong with this code? I get an exception: HTTP/1.1 302 Found
Set the TIdHTTP.HandleRedirects property to True. It is False by default.
function FetchUrl(const url: string): string; 
var 
 idhttp : TIdHTTP; 
begin 
  idhttp := TIdHTTP.Create(nil); 
  try 
    idhttp.HandleRedirects := True;
    Result := idhttp.Get(url); 
  finally 
    idhttp.Free; 
  end; 
end; 
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With