I am currently trying to connect a C# program with a Sharepoint. What I have: a Sharepoint URL, Username and a Password, no Sharepoint.dll (client machine, no Microsoft.Sharepoint namespace, so I use Sharepoint Web Services), Visual Studio 2010 Ultimate.
I followed this tutorial: http://www.scribd.com/doc/8634090/Accessing-SharePoint-Data-Using-C-Without-Running-Code-On-the-SharePoint-Server-Part-1
What I did so far:
added a "Service Reference" to my project with the URL of my Sharepoint like
https://.../content/10003194/_vti_bin/lists.asmx
and my code:
//no TestSP.Lists here...
TestSP.ListsSoapClient cl = new TestSP.ListsSoapClient();
cl.Open();
String listGUID = "A9E7107B-7AF6-42DC-A1A7-6C898D55D23E";
String viewGUID = "684F5F8A-B32E-461C-BD53-677F84A9C101";
//this is where it crashes
System.Xml.Linq.XElement data = cl.GetListItems(listGUID, viewGUID, null, null, "1000", null, "");
IEnumerable<XElement> elements = data.Elements();
foreach (XElement el in elements)
{
Console.WriteLine(el);
}
it crashes at the specified line with:
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM,Basic realm="..."'
which is most likely because I did not specify a username and password. Various tutorials on the web showed shat the credentials can be set like this:
TestSP.Credentials = System.Net.CredentialCache.DefaultCredentials;
Problem is: there is no TestSP.Lists
, so I used TestSP.ListsSoapClient
, which has no Credentials
, only ClientCredentials
, which are read-only.