Sample code for 30+ languages & platforms
Objective-C

GetHarvest - Delete Contact

See more GetHarvest Examples

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

Chilkat Objective-C Downloads

Objective-C
#import <CkoHttp.h>
#import <CkoHttpResponse.h>

BOOL success = NO;

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

CkoHttp *http = [[CkoHttp alloc] init];

// 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"];

CkoHttpResponse *resp = [[CkoHttpResponse alloc] init];
success = [http HttpNoBody: @"DELETE" url: @"https://api.harvestapp.com/v2/contacts/CONTACT_ID" response: resp];
if (success == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

int respStatusCode = [resp.StatusCode intValue];
NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
if (respStatusCode != 200) {
    NSLog(@"%@",@"Response Header:");
    NSLog(@"%@",resp.Header);
    NSLog(@"%@",@"Response Body:");
    NSLog(@"%@",resp.BodyStr);
    NSLog(@"%@",@"Failed.");
    return;
}

NSLog(@"%@",@"Success.");