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

我假設你的驅動器上有一些文件或文件夾。如果可以,您可以提供返回給您的某個電話的響應標題? –

相關問題