简体   繁体   English

无法使用Sharepoint客户端对象模型连接到Sharepoint网站

[英]Unable to connect to sharepoint site using Sharepoint Client Object Model

I'm attempting to write a console application to connect to one of our sharepoint application sites. 我试图编写一个控制台应用程序以连接到我们的SharePoint应用程序站点之一。 I'm running a basic example to ensure connectivity. 我正在运行一个基本示例以确保连接性。 The program keeps failing with the following error: The remote server returned an error: (500) Internal Server Error. 程序不断失败,并出现以下错误:远程服务器返回错误:(500)Internal Server Error。

Status: System.Net.WebExceptionStatus.ProtocolError 状态:System.Net.WebExceptionStatus.ProtocolError

I don't have access to the IIS server to check the logs. 我无权访问IIS服务器来检查日志。 My code is as follows: 我的代码如下:

        string siteUrl = "http://spsiteurl/";


        ClientContext clientContext = new ClientContext(siteUrl);
        clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
        clientContext.Credentials = new NetworkCredential("...", "...", "...");

        Web oWebsite = clientContext.Web;

        clientContext.Load(oWebsite,
            w => w.Title);

        clientContext.ExecuteQuery();

        Console.WriteLine(oWebsite.Title);

Any direction on where I could be going wrong? 关于我可能会出错的任何方向?

try below code 尝试下面的代码

    ClientContext context = new ClientContext("https://test.com/");
    System.Net.ServicePointManager.ServerCertificateValidationCallback =
        ((sender, certificate, chain, sslPolicyErrors) => true);

    string strUserName = @"abc";
    string strPassword = "pwd";
    var credentials = new NetworkCredential(strUserName, strPassword);
    Web web = context.Web;
    context.Load(web, w => w.Title);
    context.Credentials = credentials;
    context.ExecuteQuery();


    // Now, the web's properties are available and we could display 
    // web properties, such as title. 
    System.Console.WriteLine("Web Title");
    System.Console.WriteLine(web.Title);

it will work fine in console 它将在控制台中正常工作

暂无
暂无

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

相关问题 使用共享点对象模型创建新的共享点站点时出错 - Error while creating a new sharepoint site using sharepoint object model SHarePoint 2013网站集通过客户端对象模型 - SHarePoint 2013 site collection through client object model 当我尝试使用SharePoint Client Object Model和.NET应用程序在线连接共享点时出现“提供了无效的参数”错误 - “An invalid argument was supplied” error when I try to connect sharepoint online using SharePoint Client Object Model with .NET application 使用Sharepoint 2010客户端对象模型搜索站点中以特定扩展名结尾的所有文档 - Search for all documents in a site that end with a specific extention using Sharepoint 2010 Client Object Model 使用Sharepoint客户端对象模型创建类型为user,multichoice和multiuser的站点列 - Create a site-column of type user, multichoice and multiuser using Sharepoint Client Object Model 在使用客户端对象模型的Sharepoint中,如何确定URL是否代表网站 - In Sharepoint using the Client Object Model, how can I determine if a URL represents a site 通过客户端对象模型中的代理服务器连接到SharePoint Online - Connect to SharePoint Online via proxy server in Client Object Model 使用 c# 和客户端对象模型 (CSOM) 使用外部用户连接到 SharePoint Online - Connect to SharePoint Online using an external user using c# and Client Side Object Model (CSOM) Sharepoint客户端对象模型区域设置 - Sharepoint Client Object Model locale 共享点客户端对象模型错误 - Error with sharepoint client object model
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM