Skip to main content
1 of 2

Creating list content type using csom

I am not able to create a list content type using the below snippet. It throws a ServerException with additional information - "The site content type has already been added to this list."

   var list =  clientContext.Web.Lists.GetByTitle("sometitle");
   var documentCT = clientContext.Web.ContentTypes.GetById("0x0101");
   clientContext.Load(list,l=> l.ContentTypes);
   clientContext.Load(documentCT);
   clientContext.ExecuteQuery();

   var test = new ContentTypeCreationInformation(){
        Name = "TestCT", ParentContentType =documentCT };

   list.ContentTypes.Add(test);

   list.Update();
   clientContext.ExecuteQuery();

Basically, I want to create a list content type whose parent is the "Document" CT.