Sample code for 30+ languages & platforms
Lua

GetHarvest - Delete Contact

See more GetHarvest Examples

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

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

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

local http = chilkat.Http.new()

-- 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:set_request_header("User-Agent", "MyApp (yourname@example.com)")
http:set_request_header("Authorization", "Bearer ACCESS_TOKEN")
http:set_request_header("Harvest-Account-Id", "ACCOUNT_ID")

local resp = chilkat.HttpResponse.new()
local success = http:http_no_body("DELETE", "https://api.harvestapp.com/v2/contacts/CONTACT_ID", resp)
if not success then
    print(http.last_error_text)
    return
end

local respStatusCode = resp.status_code
print("Response Status Code = " .. respStatusCode)
if respStatusCode ~= 200 then
    print("Response Header:")
    print(resp.header)
    print("Response Body:")
    print(resp.body_str)
    print("Failed.")
    return
end

print("Success.")