To insert item into list using csom code. You can create a consol application using visual studio and also use the code mentioned below. You can interact with sharepoint list using JSOM,CSOM or using rest api.
List operation using csom.
List operation using csom.
using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args)
{
using (ClientContext clientContext = new ClientContext("insert url upto list"))
{
string Uname = "Your ID";
string password = "Password";
class Program {
static void Main(string[] args)
{
using (ClientContext clientContext = new ClientContext("insert url upto list"))
{
string Uname = "Your ID";
string password = "Password";
SecureString Securepasseord = GetSecureString(password);
clientContext.Credentials = new SharePointOnlineCredentials(Uname, Securepasseord); clientContext.ExecuteQuery();
List oList = clientContext.Web.Lists.GetByTitle("metalist");
ListItemCreationInformation listCreationInformation = new ListItemCreationInformation();
ListItem oListItem = oList.AddItem(listCreationInformation);
oListItem["Title"] = "This is title";
oListItem["Keywords"] = "test";
oListItem.Update();
clientContext.ExecuteQuery();
}
}
private static SecureString GetSecureString(String Password)
{
SecureString oSecurePassword = new SecureString(); foreach (Char c in Password.ToCharArray()) { oSecurePassword.AppendChar(c); } return oSecurePassword;
}
}
}
}
}
private static SecureString GetSecureString(String Password)
{
SecureString oSecurePassword = new SecureString(); foreach (Char c in Password.ToCharArray()) { oSecurePassword.AppendChar(c); } return oSecurePassword;
}
}
}
This is really nice post, I found and love this content. I will prefer this, thanks for sharing. Serp Api.
ReplyDeleteNice blog, it is very impressive.
ReplyDeleteREST API Testing Online Course
REST API Testing Course in Chennai
REST API Testing Course in Bangalore