sunil
sunil

Reputation: 300

Failed to delete the file in box v2 api

I'm following the procedure given in following url's to delete the file and folder in box api .

http://developers.box.com/docs/#files-delete-a-file

http://developers.box.com/docs/#folders-delete-a-folder

I'm using the following code to delete files in box api . I got succeded in deleting the folder but fails in deleting the file .

 NSString *str;
    if ([type isEqualToString:@"folder"])
    {
        str =  [NSString stringWithFormat:@"https://api.box.com/2.0/folders/%@?recursive=true&access_token=%@",folder_id,str_access_token];

    }
    else
    {
        str =  [NSString stringWithFormat:@"https://api.box.com/2.0/files/%@&access_token=%@&If-Match=%@",folder_id,str_access_token,etag];

    }
    ASIFormDataRequest *postParams = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:str]];
    [postParams setRequestMethod:@"DELETE"];
    [postParams startAsynchronous];
    postParams.delegate = self ;

Upvotes: 0

Views: 118

Answers (2)

user2318392
user2318392

Reputation:

You done correctly but a small mistake . need to place ? instead of & in the below lline.

str =  [NSString stringWithFormat:@"https://api.box.com/2.0/files/%@?access_token=%@&If-Match=%@",folder_id,str_access_token,etag];

Upvotes: 1

sunil
sunil

Reputation: 300

Got the solution . small mistake

NSString *str;
    if ([type isEqualToString:@"folder"])
    {
        str =  [NSString stringWithFormat:@"https://api.box.com/2.0/folders/%@?recursive=true&access_token=%@",folder_id,str_access_token];

    }
    else
    {
        str =  [NSString stringWithFormat:@"https://api.box.com/2.0/files/%@?access_token=%@&If-Match=%@",folder_id,str_access_token,etag];

    }
    ASIFormDataRequest *postParams = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:str]];
    [postParams setRequestMethod:@"DELETE"];
    [postParams startAsynchronous];
    postParams.delegate = self ;

Upvotes: 0

Related Questions