Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
GetHarvest - Delete Contact
See more GetHarvest Examples
Delete a contact. Returns a 200 OK response code if the call succeeded.Chilkat Pascal (Lazarus/Delphi) Downloads
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.HttpResponse,
Chilkat.Http;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
http: THttp;
resp: THttpResponse;
respStatusCode: Integer;
begin
success := False;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := THttp.Create;
// Implements the following CURL command:
// curl "https://api.harvestapp.com/v2/contacts/CONTACT_ID" \
// -H "Authorization: Bearer ACCESS_TOKEN" \
// -H "Harvest-Account-Id: ACCOUNT_ID" \
// -H "User-Agent: MyApp (yourname@example.com)" \
// -X DELETE
http.SetRequestHeader('User-Agent','MyApp (yourname@example.com)');
http.SetRequestHeader('Authorization','Bearer ACCESS_TOKEN');
http.SetRequestHeader('Harvest-Account-Id','ACCOUNT_ID');
resp := THttpResponse.Create;
success := http.HttpNoBody('DELETE','https://api.harvestapp.com/v2/contacts/CONTACT_ID',resp);
if (success = False) then
begin
WriteLn(http.LastErrorText);
Exit;
end;
respStatusCode := resp.StatusCode;
WriteLn('Response Status Code = ' + respStatusCode);
if (respStatusCode <> 200) then
begin
WriteLn('Response Header:');
WriteLn(resp.Header);
WriteLn('Response Body:');
WriteLn(resp.BodyStr);
WriteLn('Failed.');
Exit;
end;
WriteLn('Success.');
http.Free;
resp.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.