【问题标题】:Authentication SharePoint 2013 on-premises REST API身份验证 SharePoint 2013 本地 REST API
【发布时间】:2015-07-22 08:39:43
【问题描述】:

我有一个带有列表的本地 SharePoint 2013。我需要远程使用 REST API 从客户端应用程序(不是 Office/Sharepoint 'App')获取该列表。我不知道如何针对 SharePoint 进行身份验证。我不想使用访问令牌或基于表单的身份验证。安全证书也不起作用,因为它不是“SharePoint 应用程序”。有人可以帮助我吗?谢谢。

【问题讨论】:

    标签: asp.net-mvc rest authentication sharepoint-2013 asp.net-web-api


    【解决方案1】:

    我找到了解决方案,事实证明它非常简单。

     string url = "http://<siteUrl>/_api/web/lists";
     HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
     webRequest.AuthenticationLevel = System.Net.Security.AuthenticationLevel.MutualAuthRequested;
     webRequest.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
     webRequest.Method = "GET";
     Stream response = webRequest.GetResponse().GetResponseStream();
     StreamReader reader = new StreamReader(response);
    

    该代码会带来您网站包含的任何列表,并将结果放入流阅读器。我正在寻找一些太复杂的东西,结果发现它很简单。希望它可以帮助某人!

    【讨论】:

      猜你喜欢
      • 2017-08-06
      • 2015-06-16
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 2019-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多