Microsoft Graph API: Get Files List API, giving Empty array

醉酒当歌 提交于 2019-12-11 18:31:50

问题


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

Request snippet:

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

Response:

{"@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


回答1:


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.



来源:https://stackoverflow.com/questions/33812693/microsoft-graph-api-get-files-list-api-giving-empty-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!