How to delete ContentTypes in Sharepoint 2013/Office 365 using CSOM
In this article, we will learn about ContentType deletion in Sharepoint 2013/Office 365 using CSOM. Below is the sample CSOM code to achieve the same.
ClientContext cc = new ClientContext(siteUrl);
cc.AuthenticationMode = ClientAuthenticationMode.Default;
cc.Credentials = new SharePointOnlineCredentials(userName, pwd);
Web web = cc.Web;
ContentTypeCollection contentTypes = web.ContentTypes;
cc.Load(contentTypes);
cc.ExecuteQuery();
foreach (var item in contentTypes)
{
if (item.StringId == “0x0101009189AB5D3D2647B580DFGT56F356FB2”)
{
item. DeleteObject();
web.Update();
cc.ExecuteQuery();
}
}
You can check this blog Create-a-content-type-in-sharepoint-2013office-365-programmatically as well.
Hope it helps!! Happy Sharepointing 🙂