Sample code for 30+ languages & platforms
Node.js

GetHarvest - Delete Contact

See more GetHarvest Examples

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

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

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

    var http = new 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");

    var resp = new chilkat.HttpResponse();
    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.");

}

chilkatExample();