0

我试过API来获取iOS SDK中的文件。
我已经注册了所有范围的应用程序来读取/读取文件访问应用程序。我能够成功地使用示例代码发送邮件。 我试过的API的图形浏览器 https://graphexplorer2.azurewebsites.net/?UrlRequest=GET&text=https%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fme%2Fdrive%2Froot%2FchildrenMicrosoft Graph API:获取文件列表API,给出空阵列

请求片段:

AuthenticationManager *authManager = [AuthenticationManager sharedInstance]; 
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://graph.microsoft.com/v1.0/me/drive/root/children"]]; 
[request setHTTPMethod:@"GET"]; 
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; 
[request setValue:@"application/json, text/plain, */*" forHTTPHeaderField:@"Accept"]; 
NSString *authorization = [NSString stringWithFormat:@"Bearer %@", authManager.accessToken]; 
[request setValue:authorization forHTTPHeaderField:@"Authorization"]; 
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self]; 

if(conn) { 
    NSLog(@"Connection Successful"); 
} else { 
    NSLog(@"Connection could not be made"); 
} 
[conn start]; 

响应:

{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users('<user-email>')/drive/root/children","value":[]} 

在此先感谢您的帮助:)

权限我的示例应用程序 Permissions for my sample app

回答

1

当应用程序没有权限访问给定用户驱动器的根目录中的任何文件时,预计会出现该请求的空响应。您可以检查(例如,通过http://jwt.calebb.net)您使用的访问令牌是否有任何文件。*范围? Files.Read已足够满足该请求。

+1

它更多的是评论而不是回答。 – Panther

+0

@Marek我编辑并添加了权限。所以一切都被检查。仍然得到相同的回应。 –

+0

我假设你的驱动器上有一些文件或文件夹。如果可以,您可以提供返回给您的某个电话的响应标题? –

相关问题