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.