I got a frustrating problem: When I create a document set via Client Object Model, the document set is created as intended as far as it concerns the appearance outside the treeview. It's shown as document set with all its properties including being redirected to the document set's homepage. But, in the treeview, it is listed. Manually created document sets are not listed there, and I cannot figure out why the client object model document set is listed there. Furthermore, clicking the treeview item, it opens the document set as a folder. No document set homepage there.

Has someone got an idea?

Web web = clientContext.Web;
ContentTypeCollection listContentTypes = existingList.ContentTypes;
clientContext.Load(listContentTypes, types => types.Include(type => type.Id, type =>     type.Name, type => type.Parent));
var result = clientContext.LoadQuery(listContentTypes.Where(c => c.Name ==   "mydocsetname"));
ContentType targetDocumentSetContentType = result.FirstOrDefault();
ListItemCreationInformation newItemInfo = new ListItemCreationInformation();
newItemInfo.UnderlyingObjectType = FileSystemObjectType.Folder;
newItemInfo.LeafName = documentSetName;
newItemInfo.FolderUrl = rootFolderUrl.ToString() + dir;
ListItem newListItem = existingList.AddItem(newItemInfo);
newListItem["ContentTypeId"] = targetDocumentSetContentType.Id.ToString();
  • Hey, The code given in your question solved my problem of creating document set :-) Aug 2, 2016 at 5:26

2 Answers 2


I'd bet that it has to do with the fact that you are "creating" the document set by creating a folder and then changing its content type. I've run into other problems/inconsistencies with document sets when creating them this way.

There is a static DocumentSet.Create() method that does quite a bit more behind-the-scenes stuff to fully provision and set up a document set. I've never tried using that method through the client object model, but as it appears by the code you posted that you are using C#, not Javascript, it shouldn't be very difficult.


In addition set HTML_x0020_File_x0020_Type property to SharePoint.DocumentSet while creating a Document Set.

The following example demonstrates how to create Document Set using SharePoint 2010 CSOM:

public static void CreateDocumentSet(ClientContext ctx,string listTitle, string docSetName)
        var list = ctx.Web.Lists.GetByTitle(listTitle);

        var itemInfo = new ListItemCreationInformation();
        itemInfo.UnderlyingObjectType = FileSystemObjectType.Folder;
        itemInfo.LeafName = docSetName;
        itemInfo.FolderUrl = list.RootFolder.ServerRelativeUrl;
        var item = list.AddItem(itemInfo);
        item["ContentTypeId"] = "0x0120D520";
        item["HTML_x0020_File_x0020_Type"] = "SharePoint.DocumentSet";
  • I too got the same issue and your answer saved my time. Aug 5, 2016 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.