public static void SaveNewAnswer(string selectedFlowType, string NewTitle, string InputTit, string Desc, bool Usertype, string SubmittedBy, string filename) { using (ClientContext ctx = new ClientContext(_serverURL)) { SecureString passWord = new SecureString(); foreach (char c in _userPasswordAdmin) { passWord.AppendChar(c); } ctx.Credentials = new SharePointOnlineCredentials(_userNameAdmin, passWord); List oList = ctx.Web.Lists.GetByTitle("Submitted Data"); ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation(); ListItem oListItem = oList.AddItem(itemCreateInfo); // oListItem["New_x0020_Title"] = NewTitle; oListItem["Title"] = NewTitle; oListItem["Type_x0020_of_x0020_Submition"] = selectedFlowType; oListItem["Source"] = "Bot"; oListItem["Description"] = Desc; oListItem["Anonymous"] = Usertype; oListItem["Submitted_x0020_By"] = SubmittedBy; if (filename != "") { //string[] multifiles = filename.Split(','); //foreach (string file in multifiles) //{ // var imagePath = HttpContext.Current.Server.MapPath("~/AttachmentFiles/" + file); // FileStream fs = new FileStream(imagePath, FileMode.Open); // AttachmentCreationInformation attInfo = new AttachmentCreationInformation(); // attInfo.FileName = fs.Name; // attInfo.ContentStream = fs; // oListItem.AttachmentFiles.Add(attInfo); //} } oListItem.Update(); ctx.ExecuteQuery(); } }