Sample code for 30+ languages & platforms
Delphi DLL

Example: Http.SetUrlVar method

Demonstrates the HTTP SetUrlVar method.

Chilkat Delphi DLL Downloads

Delphi DLL
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, StringBuilder, Http;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
http: HCkHttp;
url: PWideChar;
sbJson: HCkStringBuilder;
statusCode: Integer;

begin
success := False;

http := CkHttp_Create();

url := 'https://finnhub.io/api/v1/quote?symbol={$symbol}&token={$api_key}';

// When the request is sent, the {$symbol} is replaced with "MSFT"
// and the {$api_key} is replaced with "1234567890ABCDEF"
CkHttp_SetUrlVar(http,'symbol','MSFT');
CkHttp_SetUrlVar(http,'api_key','1234567890ABCDEF');

sbJson := CkStringBuilder_Create();
success := CkHttp_QuickGetSb(http,url,sbJson);
if (success = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

statusCode := CkHttp_getLastStatus(http);
if (statusCode <> 200) then
  begin
    Memo1.Lines.Add('Status code: ' + IntToStr(statusCode));
    Memo1.Lines.Add('Error Message:');
    Memo1.Lines.Add(CkStringBuilder__getAsString(sbJson));
  end
else
  begin
    Memo1.Lines.Add('JSON Stock Quote:');
    Memo1.Lines.Add(CkStringBuilder__getAsString(sbJson));
  end;

// Output:

// JSON Stock Quote:
// {"c":522.98,"d":0.5,"dp":0.0957,"h":524.51,"l":520.86,"o":524.28,"pc":522.48,"t":1755271948}

CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbJson);

end;