Objective-C Box: Delete Folder

Back to Index

Move a folder to the trash. The recursive parameter must be included in order to delete folders that aren't empty. This example deletes the folder w/ id = 47885473705. An empty 204 response will be returned upon successful deletion. An error is thrown if the folder is not empty and the ‘recursive’ parameter is not included.

Documentation: https://developer.box.com/reference#delete-a-folder

CURL Command

curl https://api.box.com/2.0/folders/47885473705?recursive=true \
-H "Authorization: Bearer BOX_ACCESS_TOKEN" \
-X DELETE

Objective-C Example

#import <CkoRest.h>
#import <CkoStringBuilder.h>

CkoRest *rest = [[CkoRest alloc] init];
BOOL success;

//  URL: https://api.box.com/2.0/folders/47885473705?recursive=true
BOOL bTls = YES;
int port = 443;
BOOL bAutoReconnect = YES;
success = [rest Connect: @"api.box.com" port: [NSNumber numberWithInt: port] tls: bTls autoReconnect: bAutoReconnect];
if (success != YES) {
    NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);
    NSLog(@"%@",rest.LastErrorText);
    return;
}

[rest AddHeader: @"Authorization" value: @"Bearer BOX_ACCESS_TOKEN"];

CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestNoBodySb: @"DELETE" uriPath: @"/2.0/folders/47885473705?recursive=true" sb: sbResponseBody];
if (success != YES) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}