Create A List Item In SharePoint Using CSOM(Announcement List)

Steps
  1. Open Visual Studio in your system
  2. Select Console Application template and give the name "Enablefolder"
  3. Add a Microsoft.Cleint Assembly reference file in right side reference tab in Visual Studio.
  4. Replace Program.cs with the source code given below.
  1. using System;  
  2. using Microsoft.SharePoint.Client;  
  3.   
  4.   
  5. namespace GowthamArticles  
  6. {  
  7.     class CreateListItem  
  8.     {  
  9.         static void Main()  
  10.         {     
  11.               
  12.             ClientContext clientContext = new ClientContext("https://gowtham.sharepoint.com/tutorials");  
  13.             List oList = clientContext.Web.Lists.GetByTitle("Announcements");  
  14.   
  15.             ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();  
  16.             ListItem oListItem = oList.AddItem(itemCreateInfo);  
  17.             oListItem["Title"] = "Test Item!";  
  18.             oListItem["Body"] = "This sample item created programmatically";  
  19.   
  20.             oListItem.Update();  
  21.   
  22.             clientContext.ExecuteQuery();   
  23.         }  
  24.     }  
  25. }  
Thanks for reading this blog.
Ebook Download
View all
Learn
View all