我找到了解决方案。我发布了JSON正文。这是我的代码。
NSString *newDirectoryName;
NSString *str;
NSString*fid = [[boxFilePathsArray objectAtIndex:0] objectForKey:@"folderId"];
NSString * type = [[boxFilePathsArray objectAtIndex:0]objectForKey:@"type"];
NSString * str_access_token = [[arrUseraccounts objectAtIndex:[DropboxDownloadFileViewControlller getSharedInstance].index] objectForKey:@"acces_token"];
if ([type isEqualToString:@"folder"])
{
newDirectoryName =tempString;
str = [NSString stringWithFormat:@"https://api.box.com/2.0/folders/%@?access_token=%@",fid,str_access_token];
}
else
{
newDirectoryName = [NSString stringWithFormat:@"%@.pdf",tempString];
str = [NSString stringWithFormat:@"https://api.box.com/2.0/files/%@?access_token=%@",fid,str_access_token];
}
NSDictionary *cid = [[NSDictionary alloc] initWithObjectsAndKeys:newDirectoryName,@"name", nil];
NSError *error;
NSData *postData = [NSJSONSerialization dataWithJSONObject:cid options:0 error:&error];
NSMutableData *data = [[NSMutableData alloc] initWithData:postData];
ASIFormDataRequest *postParams = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:str]];
//[postParams setPostValue:newDirectoryName forKey:@"name"];
[postParams setPostBody:data];
[postParams setRequestMethod:@"PUT"];
[postParams startAsynchronous];
postParams.delegate = self ;
postParams.userInfo = [NSDictionary dictionaryWithObject:@"RenameFolder" forKey:@"id"];