Sample code for 30+ languages & platforms
JavaScript

GetHarvest - Delete Contact

See more GetHarvest Examples

Delete a contact. Returns a 200 OK response code if the call succeeded.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

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

var 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

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

var resp = new CkHttpResponse();
success = http.HttpNoBody("DELETE","https://api.harvestapp.com/v2/contacts/CONTACT_ID",resp);
if (success == false) {
    console.log(http.LastErrorText);
    return;
}

var respStatusCode = resp.StatusCode;
console.log("Response Status Code = " + respStatusCode);
if (respStatusCode !== 200) {
    console.log("Response Header:");
    console.log(resp.Header);
    console.log("Response Body:");
    console.log(resp.BodyStr);
    console.log("Failed.");
    return;
}

console.log("Success.");