I want to create a list item using SharePoint Client object model (SharePoint 2010).

        string siteURL = @"https://www.server.com:1234/sites/test/";

        using (ClientContext spcontext = new ClientContext(siteURL))
            // Connecting to SharePoint site
            spcontext.Credentials = new System.Net.NetworkCredential("UserName", "password", "domain");

            spcontext.RequestTimeout = 600000;

            spcontext.Load(spcontext.Web, w => w.Title, w => w.ServerRelativeUrl, w => w.Lists);

I am using above code to connect to SharePoint site, but it is throwing error Cannot contact site at the specified URL https://www.server.com:1234/sites/test/

Let me know where i dm doing wrong.

1 Answer 1


Finally i found my answer after lots of research. It was the problem related to Authorization, the SharePoint server which i wanted to refer, had a Form based Authentication. So i updated my code according to that and it worked fine.

Please find my below updated code

 using (ClientContext spcontext = new ClientContext("siteURL"))
            spcontext.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;
            spcontext.FormsAuthenticationLoginInfo = new FormsAuthenticationLoginInfo("UserName","Password");
            spcontext.Load(spcontext.Web, w => w.Title, w => w.ServerRelativeUrl, w => w.Lists);

This is working fine.

  • I am facing a similar issue with my code. The server in my case seems to have both the authentication modes enabled. I would like to know if in this case which authentication should I use to create clientcontext of my SP2010 site? FYI, I do not have access to server and I am writing a CSOM application to download the files from server. Regards Agasthya
    – agasthya
    Commented Sep 6, 2017 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.