【问题标题】:401:Unauthorized Error when calling Sharepoint Lists Web Service from .NET401:从 .NET 调用 Sharepoint 列表 Web 服务时出现未经授权的错误
【发布时间】:2015-05-18 20:17:01
【问题描述】:

我正在尝试使用 Web 服务 (http://test.sharepoint.com/_vti_bin/Lists.asmx) 从我的 ASP.NET 代码在 Sharepoint 站点中创建列表。我使用的代码如下。我确定我有足够的权限访问该共享点站点。

sharepoint.enhanced1.Lists wsLists = new SharePoint_Test.sharepoint.enhanced1.Lists();
        wsLists.PreAuthenticate = true;
        wsLists.Credentials = System.Net.CredentialCache.DefaultCredentials;
        wsLists.AddList("Test_Code", "testing", 103);

此代码给了我错误:- 请求失败,HTTP 状态为 401:未授权。 谁能帮我解决这个问题。

【问题讨论】:

  • 它只与授权有关。交叉检查您的凭据和访问权限。
  • 好吧,我可以访问 sharepoint 站点(完全访问权限),并且可以从 sharepoint 手动创建列表。不确定还需要什么其他访问权限。

标签: asp.net web-services sharepoint


【解决方案1】:

它现在正在工作.. 我使用了一些错误的 asmx URL。 我用的是http://test.sharepoint.com/Lists/_vti_bin/Lists.asmx 但正确的 URL 应该是 http://test.sharepoint.com/_vti_bin/Lists.asmx (**NO /Lists/)。 奇怪的是,两个 URL 在浏览器中打开都没有任何问题,但在代码中失败。

谢谢...

【讨论】:

    【解决方案2】:

    尝试使用默认网络凭据

    wsLists.Credentials = System.Net.CredentialCache.DefaultCredentials;
    

    【讨论】:

    • 我使用了完全相同的东西..不起作用,我使用了 DefaultNetworkCredentials,仍然没有运气。我能够让“getListCollection”方法工作,但是现在当我使用 UpdateListItems("TEST", element);我得到 Microsoft.Sharepoint.SoapServer 异常。
    【解决方案3】:

    我遇到了同样的错误,最后在 IIS 管理器中为我的 Sharepoint 站点禁用了 ASP.NET 模拟。

    【讨论】:

      猜你喜欢
      • 2017-02-23
      • 1970-01-01
      • 2012-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多