ClientContext API 不会返回 Teams SharePoint 网站中的项目,但在 SharePoint Online 中工作正常

问题描述 投票:0回答:1

针对 SharePoint Online 中的网站与属于团队一部分的网站使用基于“旧版”SharePoint ClientContext/CSOM 的 API 会有区别吗?

我有一些代码在与一般 SPO 站点交谈时工作得很好。

string camlXML = "<View><Query><Where><And><Geq><FieldRef Name='EventDate' /><Value " +
                "Type='DateTime'>" + (DateTime.UtcNow.AddDays(daysPast * -1).ToString("o", System.Globalization.CultureInfo.InvariantCulture) +
                "</Value></Geq><Leq><FieldRef Name='EventDate'/><Value Type='DateTime'>" +
                DateTime.UtcNow.AddDays(daysForward).ToString("o", System.Globalization.CultureInfo.InvariantCulture)) +
                "</Value></Leq></And></Where></Query></View>";


using (var cc = new AuthenticationManager().GetACSAppOnlyContext(instance.url, instance.apiKey, instance.apiSecret))
{    
    Web web = cc.Web;
    var spTimezone = web.RegionalSettings.TimeZone;

    List eventsList = web.Lists.GetByTitle(instance.calendarTitle);
    CamlQuery query = new CamlQuery();
    var list = web.Lists;

    query.ViewXml = camlXML;
    ListItemCollection eventsItems = eventsList.GetItems(query);
    cc.Load(eventsItems);
    cc.ExecuteQuery();

    Logger.Info("Found " + eventsItems.Count + " items in " + instance.name);
}

但是,如果我对我现在正在处理的网站运行此命令,我会得到零结果。如果我针对多个网站运行我开发的此代码(未绑定到团队),它会按预期工作并返回列表项的集合。

我觉得我的身份验证正在工作,就好像我拼写的 CalendarTitle 错误一样,我收到一个异常,列表在 URL 中不存在。

我似乎也无法看到网站中所有列表的列表等。

这是由于该特定站点的差异造成的吗?当它在我的所有其他非基于 Teams 的网站上运行良好时,为什么我无法获得任何结果?

sharepoint microsoft-teams sharepoint-online csom
1个回答
0
投票

这可能仍然是身份验证问题。根据此文档

自 2023 年 11 月 27 日起,使用 Azure ACS(访问控制服务)进行 SharePoint Online 已停用...

© www.soinside.com 2019 - 2024. All rights reserved.