Sample code for 30+ languages & platforms
Pascal (Lazarus/Delphi)

Shopify Basic Authentication: Get List of Products

See more Shopify Examples

Demonstrates how to send a simple HTTP GET request with Basic authentication to get a list of products.

Chilkat Pascal (Lazarus/Delphi) Downloads

Pascal (Lazarus/Delphi)
program ChilkatDemo;

// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  SysUtils,
  CkDllLoader,
  Chilkat.Http;

// ---------------------------------------------------------------------------

procedure RunDemo;
var
  http: THttp;
  jsonStr: string;

begin
  //  This example requires the Chilkat API to have been previously unlocked.
  //  See Global Unlock Sample for sample code.

  http := THttp.Create;

  //  Use your Shopify store's Admin API key and password.
  http.Login := 'admin3_api_key';
  http.Password := 'admin3_password';
  http.BasicAuth := True;

  jsonStr := http.QuickGetStr('https://mystore.myshopify.com/admin/api/2020-07/products.json');
  if (http.LastMethodSuccess <> True) then
    begin
      WriteLn(http.LastErrorText);
      Exit;
    end;

  WriteLn('Response status code: ' + http.LastStatus);
  WriteLn('JSON response:');
  WriteLn(jsonStr);


  http.Free;

end;

// ---------------------------------------------------------------------------

begin

  try
    RunDemo;
  except
    on E: Exception do
      WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
  end;

  WriteLn;
  {$IFDEF MSWINDOWS}
  WriteLn('Press Enter to exit...');
  ReadLn;
  {$ENDIF}
end.