【问题标题】:Office 365 iOS: Not able to fetch List Items from Office 365 SDKOffice 365 iOS:无法从 Office 365 SDK 获取列表项
【发布时间】:2015-03-17 22:56:16
【问题描述】:

我已经添加了公告应用程序并添加了一些项目,现在我想从我的公告列表中获取项目,所以我使用了以下代码

token_Obtained_During_first_time_Login:这是我第一次使用ADAuthenticationContext类的acquireTokenWithResource方法登录时得到的令牌

- (void)getClientList {

NSString *appToken = [[NSUserDefaults standardUserDefaults]
 valueForKey:@"token_Obtained_During_first_time_Login"];
NSString* hostName = @"https://myTenant.sharepoint.com/sites/myApp";


OAuthentication *credentials = [[OAuthentication alloc] initWith:appToken];
ListClient *client = [[ListClient alloc]
                  initWithUrl:hostName
                  credentials:credentials];

NSURLSessionTask* task =  [client getListItems:@"MyAnnouncements" 
callback:^(NSMutableArray *listItems, NSError *error)  {
    if (error==nil) {
    NSLog(@"%@",listItems);
    }
}];

[task resume];

}

我什至调试了 365 代码,它为我提供了 getListItems 的以下 URL:回调方法

https://myTenant.sharepoint.com/sites/myApp/_api/lists/GetByTitle('MyAnnouncements')/Items

我什至尝试过使用示例代码附带的 getTokenWith 方法

- (void)getAnnouncementList:(void (^)(ListClient *))callback{
NSString* hostName = @"https://myTenant.sharepoint.com";

[self getTokenWith:hostName :true completionHandler:^(NSString *token) {
OAuthentication *credentials = [[OAuthentication alloc] initWith:token];

callback([[ListClient alloc]initWithUrl:hostName credentials:credentials]);
 }];
}

但还是没有运气,我得到的列表为零

请指导如何解决这个问题,我什至验证了 Azure 目录中的权限,一切似乎都很好,能够获取一个驱动器、邮件和日历的数据,但列表是我卡住的地方。

每次我调用上面的代码时,我都会得到响应 nil 不确定传递了什么错误,我猜是令牌。

【问题讨论】:

标签: ios sharepoint office365


【解决方案1】:

我通过更改 Office 365 的 ListClient.m 文件中的 apiUrl 解决了这个问题。

我所做的只是将其更改为

const NSString *apiUrl = @"/sites/mobileApp/_api/web/Lists";

进行上述更改就可以了,现在我可以访问所有列表数据。

【讨论】:

    猜你喜欢
    • 2015-07-15
    • 1970-01-01
    • 1970-01-01
    • 2015-09-25
    • 2015-03-07
    • 2015-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多