Microsoft Graph API:获取文件列表API,提供空数组 [英] Microsoft Graph API: Get Files List API, giving Empty array

查看:115
本文介绍了Microsoft Graph API:获取文件列表API,提供空数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用API​​来获取iOS SDK中的文件.
我已经在所有范围内注册了应用程序,以对应用程序进行读写文件访问.我能够使用示例代码成功发送邮件. 我在Graph Explorer中尝试了API

I tried API to fetch the files in iOS SDK.
I have registered app with all the scopes to read/readwrite files access to the app. I was able to send the mail using sample code successfully. I tried the APIs in Graph Explorer https://graphexplorer2.azurewebsites.net/?UrlRequest=GET&text=https%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fme%2Fdrive%2Froot%2Fchildren

请求代码段:

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":[]}

在此先感谢您的帮助:)

Thanks in Advance for the help :)

我的示例应用程序的权限

Permissions for my sample app

推荐答案

当应用无权访问给定用户驱动器根目录中的任何文件时,对于该请求的响应为空.您能否检查(例如,通过 http://jwt.calebb.net )是否使用了访问令牌有任何Files.*范围吗? Files.Read足以满足该请求.

An empty response for that request is expected when the app doesn't have permission to access any files in the root directory of a given user's drive. Could you check (e.g. via http://jwt.calebb.net) if the access token that you're using has any Files.* scopes? Files.Read is sufficient for that request.

这篇关于Microsoft Graph API:获取文件列表API,提供空数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆