Sample code for 30+ languages & platforms
Tcl

GetHarvest - Delete Contact

See more GetHarvest Examples

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

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

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

set http [new_CkHttp]

# 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

CkHttp_SetRequestHeader $http "User-Agent" "MyApp (yourname@example.com)"
CkHttp_SetRequestHeader $http "Authorization" "Bearer ACCESS_TOKEN"
CkHttp_SetRequestHeader $http "Harvest-Account-Id" "ACCOUNT_ID"

set resp [new_CkHttpResponse]

set success [CkHttp_HttpNoBody $http "DELETE" "https://api.harvestapp.com/v2/contacts/CONTACT_ID" $resp]
if {$success == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkHttpResponse $resp
    exit
}

set respStatusCode [CkHttpResponse_get_StatusCode $resp]
puts "Response Status Code = $respStatusCode"
if {$respStatusCode != 200} then {
    puts "Response Header:"
    puts [CkHttpResponse_header $resp]
    puts "Response Body:"
    puts [CkHttpResponse_bodyStr $resp]
    puts "Failed."
    delete_CkHttp $http
    delete_CkHttpResponse $resp
    exit
}

puts "Success."

delete_CkHttp $http
delete_CkHttpResponse $resp