Sample code for 30+ languages & platforms
Objective-C

MYOB: Delete a Category

See more MYOB Examples

Sends a DELETE to delete a category.

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 --request DELETE "https://ar1.api.myob.com/accountright/c06778dd-4371-4a83-975f-522df65d7574/GeneralLedger/Category/{{category_id}}" \
//   --header "Authorization: Bearer ACCESS_TOKEN" \
//   --header "x-myobapi-key: This is your API Key" \
//   --header "x-myobapi-version: v2" \
//   --header "Accept-Encoding: gzip,deflate"

[http SetRequestHeader: @"Authorization" value: @"Bearer ACCESS_TOKEN"];
[http SetRequestHeader: @"x-myobapi-key" value: @"This is your API Key"];
[http SetRequestHeader: @"Accept-Encoding" value: @"gzip,deflate"];
[http SetRequestHeader: @"x-myobapi-version" value: @"v2"];

CkoHttpResponse *resp = [[CkoHttpResponse alloc] init];
success = [http HttpNoBody: @"DELETE" url: @"https://ar1.api.myob.com/accountright/c06778dd-4371-4a83-975f-522df65d7574/GeneralLedger/Category/{{category_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.");