(Swift 2) GetHarvest - Delete Contact
Delete a contact. Returns a 200 OK response code if the call succeeded. For more information, see https://help.getharvest.com/api-v2/clients-api/clients/contacts/
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()
var success: Bool
// 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", value: "MyApp (yourname@example.com)")
http.SetRequestHeader("Authorization", value: "Bearer ACCESS_TOKEN")
http.SetRequestHeader("Harvest-Account-Id", value: "ACCOUNT_ID")
var resp: CkoHttpResponse? = http.QuickRequest("DELETE", url: "https://api.harvestapp.com/v2/contacts/CONTACT_ID")
if http.LastMethodSuccess == false {
print("\(http.LastErrorText)")
return
}
var respStatusCode: Int = resp!.StatusCode.intValue
print("Response Status Code = \(respStatusCode)")
if respStatusCode != 200 {
print("Response Header:")
print("\(resp!.Header)")
print("Response Body:")
print("\(resp!.BodyStr)")
print("Failed.")
resp = nil
return
}
resp = nil
print("Success.")
}
|