Crear Item en Lista de SharePoint usando CSOM

A través de una aplicación de consola podemos crear items en una lista utilizando la librería cliente de SharePoint:

string siteUrl = "https://mytenant.sharepoint.com/sites/mysite";

using (ClientContext clientContext = new ClientContext(siteUrl))
{
    SecureString passWord = new SecureString();
    foreach (char c in "myPassword".ToCharArray()) passWord.AppendChar(c);
    clientContext.Credentials = new SharePointOnlineCredentials("myMail@myDomain.com", passWord);

    List oList = clientContext.Web.Lists.GetByTitle("myList");

    ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
    ListItem oListItem = oList.AddItem(itemCreateInfo);
    oListItem["Title"] = "Item Title";

    oListItem.Update();
    clientContext.ExecuteQuery();
}

No Responses

Leave a Reply

Your email address will not be published. Required fields are marked *