Sample code for 30+ languages & platforms
Delphi DLL

Xero Delete Account

See more Xero Examples

Deletes an account in a Xero company (Accounting API).

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

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
http: HCkHttp;
jsonToken: HCkJsonObject;
url: PWideChar;
resp: HCkHttpResponse;

begin
success := False;

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

http := CkHttp_Create();

jsonToken := CkJsonObject_Create();
success := CkJsonObject_LoadFile(jsonToken,'qa_data/tokens/xero-access-token.json');
if (success = False) then
  begin
    Memo1.Lines.Add(CkJsonObject__lastErrorText(jsonToken));
    Exit;
  end;

CkHttp_putAuthToken(http,CkJsonObject__stringOf(jsonToken,'access_token'));

// Replace the value here with an actual tenant ID obtained from this example:
// Get Xero Tenant IDs
CkHttp_SetRequestHeader(http,'Xero-tenant-id','83299b9e-5747-4a14-a18a-a6c94f824eb7');

CkHttp_putAccept(http,'application/json');

url := 'https://api.xero.com/api.xro/2.0/Accounts/54ddab14-4a8d-45cf-86be-076c99a0cea0';

resp := CkHttpResponse_Create();
success := CkHttp_HttpNoBody(http,'DELETE',url,resp);
if (success = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

// A 200 status code indicates success.
Memo1.Lines.Add('Response Status Code: ' + IntToStr(CkHttpResponse_getStatusCode(resp)));
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkHttpResponse__bodyStr(resp));

CkHttp_Dispose(http);
CkJsonObject_Dispose(jsonToken);
CkHttpResponse_Dispose(resp);

end;