Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I m trying to hit SP Online asmx web services and update a list item. I have the code below which I m trying to run.

        /*Declare and initialize a variable for the Lists Web service.*/
        webReference.Lists listService = new webReference.Lists();

        SecureString password = new SecureString();
        foreach (char c in "password".ToCharArray()) password.AppendChar(c);

        listService.Credentials = new SharePointOnlineCredentials("yourname@yoursite.com", password);

        /*Set the Url property of the service for the path to a subsite.*/
        listService.Url = "https://yoursite.sharepoint.com/sites/SiteCollectionName/_vti_bin/lists.asmx";

        /*Get Name attribute values (GUIDs) for list and view. */
        System.Xml.XmlNode ndListView = listService.GetList("ListName");
        string strListID = ndListView.ChildNodes[0].Attributes["Name"].Value;
        string strViewID = ndListView.ChildNodes[1].Attributes["Name"].Value;

        /*Create an XmlDocument object and construct a Batch element and its attributes. Note that an empty ViewName parameter causes the method to use the default view. */
        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
        System.Xml.XmlElement batchElement = doc.CreateElement("Batch");
        batchElement.SetAttribute("OnError", "Continue");
        batchElement.SetAttribute("ListVersion", "1");
        batchElement.SetAttribute("ViewName", strViewID);

        /*Specify methods for the batch post using CAML. To update or delete, specify the ID of the item, and to update or add, specify 
        the value to place in the specified column.*/
        batchElement.InnerXml = "<Method ID='1' Cmd='New'>" +
            //"<Field Name='ID'>new</Field>" +
           "<Field Name='Title'>New Item</Field></Method>";

        /*Update list items. This example uses the list GUID, which is recommended, but the list display name will also work.*/
            listService.UpdateListItems(strListID, batchElement);
            Console.WriteLine("Item Added");
        catch (Exception ex)

Updated I m getting the following error at listService.GetList("ListName") + Stack Trace

 Server was unable to process request. ---> Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

 at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
 at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
 at WebApplication1.webreference.Lists.GetListAndView(String listName, String viewName) in e:\Code\WebApplication1\WebApplication1\Web References\webreference\Reference.cs:line 262
 at WebApplication1.WebForm1.Page_Load(Object sender, EventArgs e) in e:\Code\WebApplication1\WebApplication1\WebForm1.aspx.cs:line 28
 at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
 at System.Web.UI.Control.OnLoad(EventArgs e)
 at System.Web.UI.Control.LoadRecursive()
 at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
share|improve this question
Since SOAP web services are officially deprecated, why just not to utilize CSOM or REST APIs? –  Vadim Gremyachev Jun 12 '14 at 14:05
Just because it is deprecated doesn't mean it still can't be used for the forseeable future. InfoPath is officially deprecated and there are still a ton of questions here about InfoPath. –  PirateEric Jun 12 '14 at 15:03
what is the error, could you please post the complete error? –  Waqas Sarwar MCSE Jun 13 '14 at 4:18
I have updated the exception details along with the stack trace. –  bkk Jun 13 '14 at 5:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.