简体   繁体   English

使用 Sharepoint Online 2013 从 Sharepoint Webservice 访问列表

[英]Accessing list from Sharepoint Webservice with Sharepoint Online 2013

I am trying to access a list from sharepoint via the web services.我正在尝试通过 Web 服务从 sharepoint 访问列表。

I have tried lots of different web reference URLS for my web service.我为我的网络服务尝试了许多不同的网络参考 URL。

The list is found at :该列表位于:

example.com/sites/dms/_layouts/15/start.aspx#/Lists/Documents/AllItems.aspx

the Web service URL I am using now is我现在使用的 Web 服务 URL 是

https://example.com/sites/dms/_vti_bin/lists.asmx

Obviously example.com is not the real URL.显然 example.com 不是真正的 URL。

when I run the code当我运行代码时

service.GetList("Documents");

I get the error:我收到错误:

List does not exist.列表不存在。
The page you selected contains a list that does not exist.您选择的页面包含一个不存在的列表。 It may have been deleted by another user.它可能已被其他用户删除。
0x82000006 0x82000006

My full code (many things are just for testing purposes):我的完整代码(许多内容仅用于测试目的):

public void UpdateList()
{
    MKLists.Lists service = GetService();

    string targetSite = "https://mywebpage.com/sites/dms";

    using (ClientContext ctx = ClaimClientContext.GetAuthenticatedContext(targetSite))
    {
        if (ctx != null)
        {
            ctx.Load(ctx.Web); // Query for Web
            ctx.ExecuteQuery(); // Execute
            string test = (ctx.Web.Title);
        }
    }

    CookieCollection authCookie = ClaimClientContext.GetAuthenticatedCookies(targetSite, 925, 525);

    service.CookieContainer = new CookieContainer();
    service.CookieContainer.Add(authCookie);

    XmlNode tester = service.GetList("Documents");
}


    private MKLists.Lists GetService()
    {
        MKLists.Lists myService = new MKLists.Lists();
        myService.Credentials = System.Net.CredentialCache.DefaultCredentials;
        return myService;
    }

change this line:改变这一行:

MKLists.Lists service = GetService();

with

MKLists.Lists service = new MKLists.Lists();

i hope this helps.我希望这有帮助。

Edit编辑

according to your comment in the answer here is the update @Michael try changing your targetsite url to根据您在答案中的评论,更新@Michael 尝试将您的目标站点网址更改为

string targetSite = "https://mywebpage.com/sites/dms/_vti_bin/Lists.asmx";

hope this time it helps希望这次有帮助

原来这与子站点有关..这条线解决了这个问题:

service.Url = "https://mywebpage.com/sites/dms/_vti_bin/lists.asmx";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM