Ios xCode Dropbox(400)错误
我在使用dropbox api iOS登录后,尝试向我的个人dropbox帐户发送pdf时出错 错误如下 “[警告]DropboxSDK:向/1/files\u put/kDBRootAppFolder/Music.pdf发出请求时出错-(400)预期“root”为“dropbox”、“sandbox”或“auto”,获得“kDBRootAppFolder” 下面是我在Xcode iOS项目中设置dropbox的步骤 在我的AppDelegate.m中的didFinishLaunchingWithOptions中,我有以下选项:Ios xCode Dropbox(400)错误,ios,xcode,dropbox-api,Ios,Xcode,Dropbox Api,我在使用dropbox api iOS登录后,尝试向我的个人dropbox帐户发送pdf时出错 错误如下 “[警告]DropboxSDK:向/1/files\u put/kDBRootAppFolder/Music.pdf发出请求时出错-(400)预期“root”为“dropbox”、“sandbox”或“auto”,获得“kDBRootAppFolder” 下面是我在Xcode iOS项目中设置dropbox的步骤 在我的AppDelegate.m中的didFinishLaunchingWit
DBSession *dbSession = [[DBSession alloc]
initWithAppKey:@"MYDROPBOXAPPKEY"
appSecret:@"MYDROPBOXAPPSECRET"
root:@"kDBRootAppFolder"]; // either kDBRootAppFolder or kDBRootDropbox
[DBSession setSharedSession:dbSession];
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
sourceApplication:(NSString *)source annotation:(id)annotation {
if ([[DBSession sharedSession] handleOpenURL:url]) {
if ([[DBSession sharedSession] isLinked]) {
NSLog(@"App linked successfully!");
// At this point you can start making API calls
}
[[NSNotificationCenter defaultCenter]
postNotificationName:@"isDropboxLinked"
object:[NSNumber numberWithBool:[[DBSession sharedSession] isLinked]]];
return YES;
}
// Add whatever other url handling code is requires here if applicale
return NO;
}
在AppDelegate.m中,我还添加了以下内容:
DBSession *dbSession = [[DBSession alloc]
initWithAppKey:@"MYDROPBOXAPPKEY"
appSecret:@"MYDROPBOXAPPSECRET"
root:@"kDBRootAppFolder"]; // either kDBRootAppFolder or kDBRootDropbox
[DBSession setSharedSession:dbSession];
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
sourceApplication:(NSString *)source annotation:(id)annotation {
if ([[DBSession sharedSession] handleOpenURL:url]) {
if ([[DBSession sharedSession] isLinked]) {
NSLog(@"App linked successfully!");
// At this point you can start making API calls
}
[[NSNotificationCenter defaultCenter]
postNotificationName:@"isDropboxLinked"
object:[NSNumber numberWithBool:[[DBSession sharedSession] isLinked]]];
return YES;
}
// Add whatever other url handling code is requires here if applicale
return NO;
}
在我的ViewController.m中,我添加了以下内容并将其链接到UIButton
- (void)didPressLink {
if (![[DBSession sharedSession] isLinked]) {
[[DBSession sharedSession] link];
}
}
我的视图中也有这个
self.restClient = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
self.restClient.delegate = self;
我能够点击我的按钮,接收Dropbox登录屏幕,并使用我的个人帐户凭据成功登录。当我成功登录“App linked successfully!”时,我收到以下NSLog响应。请参阅上面包含此NSLog语句的AppDelegate.m中的代码。到目前为止还不错(我认为)
现在我有一个按钮,它创建了一个pdf文件,我想发送到dropbox。pdf创建成功。现在我有了将文件发送到dropbox的代码(filename是我的pdf文件的名称,在这个场景中它恰好被称为Music.pdf)
这就是我得到“DropboxSDK:error making request to/1/fileops/delete-(400)预期'root'为'dropbox'、'sandbox'或'auto';得到'kDBRootAppFolder'”的地方。为什么我缺少什么
注意:一旦我使用个人凭据成功登录并收到此错误,如果我返回到我的AppDelegate.m并将根目录从kDBRootAppFolder更改为sandbox,然后再次运行应用程序,并尝试结束将我的Music.pdf文件发送到dropbox,则此错误将正常工作。这不是解决方案,因为如果我从我的个人dropbox登录断开连接,然后再次尝试登录,如果我将根目录保留为kDBRootAppFolder,则不会如上面所述“App linked successfully!”。想法?….看起来您提供的kDBRootAppFolder是一个字符串,而不是常量。Dropbox SDK定义kDBRootAppFolder常量,以便将正确的“根”发送到Dropbox API本身 那么这个,
root:@"kDBRootAppFolder"];
应该是:
root:kDBRootAppFolder];