Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#控制台和sharepoint链接_C#_Sharepoint_Integration_Sp - Fatal编程技术网

C#控制台和sharepoint链接

C#控制台和sharepoint链接,c#,sharepoint,integration,sp,C#,Sharepoint,Integration,Sp,这是用于从sharepoint网站获取数据的代码 string siteUrl = "https://sharesss.xyz.net/sites/xxx-xxx/training/Lists/"; System.Net.NetworkCredential cred= new System.Net.NetworkCredential("username", "password", "Domainname"); ClientContext context = new ClientCont

这是用于从sharepoint网站获取数据的代码

 string siteUrl = "https://sharesss.xyz.net/sites/xxx-xxx/training/Lists/";

 System.Net.NetworkCredential cred= new System.Net.NetworkCredential("username", "password", "Domainname");

 ClientContext context = new ClientContext(siteUrl);


      context.Credentials = cred;  
            Web web = context.Web;
            context.Load(web);
            context.ExecuteQuery();
并且执行显示错误:

没有名为“/sites/XXXXXX/training/Lists/\u vti\u bin/sites.asmx\”的网站

如何解决此问题?

string siteUrl=@”https://sharesss.xyz.net/sites/xxx-xxx/training";
string siteUrl = @"https://sharesss.xyz.net/sites/xxx-xxx/training";
                System.Net.NetworkCredential cred = new System.Net.NetworkCredential("username", "password", "Domainname");
                ClientContext clientContext = new ClientContext(siteUrl);

                Web web = clientContext.Web;

                clientContext.Credentials = cred;
SharePointOnlineCredentials(  (username).ToString(), FetchPasswordFromConsole());
                List oList = clientContext.Web.Lists.GetByTitle("Name Of List");
                CamlQuery camlQuery = new CamlQuery();
                camlQuery.ViewXml = "<View><Query><Where><Geq><FieldRef Name='ID'/>" +
                                    "<Value Type='Number'>10</Value></Geq></Where></Query><RowLimit>100</RowLimit></View>";
                ListItemCollection collListItem = oList.GetItems(camlQuery);
                clientContext.Load(web.Lists);
                clientContext.Load(oList);
                clientContext.Load(collListItem);
                clientContext.ExecuteQuery();
System.Net.NetworkCredential cred=新的System.Net.NetworkCredential(“用户名”、“密码”、“域名”); ClientContext=新的ClientContext(siteUrl); Web=clientContext.Web; clientContext.Credentials=cred; SharePointOnlineCredentials((用户名).ToString(),FetchPasswordFromConsole()); List oList=clientContext.Web.Lists.GetByTitle(“列表名称”); CamlQuery CamlQuery=新的CamlQuery(); camlQuery.ViewXml=“”+ "10100"; ListItemCollection collListItem=oList.GetItems(camlQuery); clientContext.Load(web.Lists); clientContext.Load(oList); 加载(collListItem); clientContext.ExecuteQuery();

像这样更改代码,它就可以工作。

您的第一行代码将更改为

字符串siteUrl=“”

而不是


string siteUrl=“”;

您确定站点上存在web吗?我如何检查?我仅限于此。但我在浏览器中使用此链接。然后它就工作了。您提供的站点不可用。您想向其提出一些请求吗?或者?请更好地解释您的问题!