Sample code for 30+ languages & platforms
Delphi DLL

Lightspeed - Delete a Product

See more Lightspeed Examples

Remove an existing product based on the unique identifier

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, HttpResponse, Http;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
http: HCkHttp;
resp: HCkHttpResponse;
respStatusCode: Integer;

begin
success := False;

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

http := CkHttp_Create();

// Implements the following CURL command:

// curl -X DELETE https://api.webshopapp.com/en/products/PRODUCT_ID.json \
//   -u API_KEY:API_SECRET

// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code

CkHttp_putLogin(http,'API_KEY');
CkHttp_putPassword(http,'API_SECRET');

// Use the correct cluster for your shop.  Here are the choices:
// eu1 https://api.webshopapp.com/en/
// us1 https://api.shoplightspeed.com/en/
resp := CkHttpResponse_Create();
success := CkHttp_HttpNoBody(http,'DELETE','https://api.webshopapp.com/en/products/PRODUCT_ID.json',resp);
if (success = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

respStatusCode := CkHttpResponse_getStatusCode(resp);
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode <> 204) then
  begin
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(CkHttpResponse__header(resp));
    Memo1.Lines.Add('Response Body:');
    Memo1.Lines.Add(CkHttpResponse__bodyStr(resp));
    Memo1.Lines.Add('Failed.');
    Exit;
  end;
Memo1.Lines.Add('Success.');

CkHttp_Dispose(http);
CkHttpResponse_Dispose(resp);

end;