0

我正在按照以下 url 中给出的程序删除 box api 中的文件和文件夹。

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

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

我正在使用以下代码删除 box api 中的文件。我成功删除了文件夹,但删除文件失败。

 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 ;
4

2 回答 2

1

你做得对,但有一个小错误。需要放置吗?而不是 & 在下面的行中。

str =  [NSString stringWithFormat:@"https://api.box.com/2.0/files/%@?access_token=%@&If-Match=%@",folder_id,str_access_token,etag];
于 2014-08-16T06:23:38.870 回答
0

得到了解决方案。小错误

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 ;
于 2014-08-16T06:18:43.637 回答