I want to add a new item to a sharepoint list using /_vti_bin/Lists.asmx web service.

I have used the following code

        SharePointListService.Lists currentListService = new SharePointListService.Lists();
        currentListService.Credentials = new System.Net.NetworkCredential("UserName", "Password");
        XmlDocument doc = new XmlDocument();
        XmlElement batch_element = doc.CreateElement("Batch");
        string item = "<Method ID=\"1\" Cmd=\"New\">" + "<Field Name=\"ID\">New</Field>" + "<Field Name=\"Title\">This is a test</Field>" + "</Method>";
        batch_element.InnerXml = item;
        currentListService.UpdateListItems("Resources", batch_element);

This is giving me an Access Denied Error. Am I doing something wrong in code or is there any other work around to add list item to Sharepoint Online list using /_vti_bin/Lists.asmx webservice.


Finally I got my issue resolved. We can directly authenticate Sharepoint Online site by using the below code

using (ClientContext clientContext = new ClientContext(siteURL))
    SecureString passWord = new SecureString();
    foreach (char c in "password".ToCharArray()) passWord.AppendChar(c);
    clientContext.Credentials = new SharePointOnlineCredentials(siteUserName, passWord);
    Web web = clientContext.Web;

Here we can use client side object model to authenticate the Sharepoint online site.

Read more about it here:

Authenticating .NET Client Object Model


I don't think you can authorize towards #sharepoint-online via NetworkCredentials - try using claims instead:

How to do active authentication to Office 365 and SharePoint Online

  • Thanks Dag, I have worked out the problem using client side object model. – Sushri Dec 4 '13 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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