Sample code for 30+ languages & platforms
PowerShell

GetHarvest - Delete Contact

See more GetHarvest Examples

Delete a contact. Returns a 200 OK response code if the call succeeded.

Chilkat PowerShell Downloads

PowerShell
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"

$success = $false

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

$http = New-Object Chilkat.Http

# 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 = New-Object Chilkat.HttpResponse
$success = $http.HttpNoBody("DELETE","https://api.harvestapp.com/v2/contacts/CONTACT_ID",$resp)
if ($success -eq $false) {
    $($http.LastErrorText)
    exit
}

$respStatusCode = $resp.StatusCode
$("Response Status Code = " + $respStatusCode)
if ($respStatusCode -ne 200) {
    $("Response Header:")
    $($resp.Header)
    $("Response Body:")
    $($resp.BodyStr)
    $("Failed.")
    exit
}

$("Success.")