I am trying to create a folder in a document library with a custom content type. The custom content type is based on default document set content type.

The code below is straight forward in creating a folder, but I can't seem to find a way to assign the content type to that folder. Any help is much appreciated.

var pCreate = jQuery.ajax({
"url"        : _spPageContextInfo.siteAbsoluteUrl + "/_api/Web/Folders/add('SiteCollectionDocuments/newfolder')",
"type"       : "POST",
"headers"    : { 
                "accept"          : "application/json; odata=verbose", 
                "content-type"    : "application/json; odata=verbose",
                "X-RequestDigest" : $("#__REQUESTDIGEST").val()

jQuery.when(pCreate).always(function (data){
  • You need to pass the Slug in headers. Try using solution given here and here Commented Oct 6, 2022 at 4:10

1 Answer 1


Use this SharePoint REST API code to create a folder with document set content type:

function createFolder(libraryName, folderName, folderContentTypeId) {
    //site URL
    var webUrl = _spPageContextInfo.webAbsoluteUrl;
    // path of the SharePoint library
    let libraryUrl = webUrl + "/" + libraryName;

    var folderPayload = {
        'Title': folderName,
        'Path': libraryUrl

    //Create Folder resource
        url: webUrl + "/_vti_bin/listdata.svc/" + libraryName,
        type: "POST",
        contentType: "application/json;odata=verbose",
        data: JSON.stringify(folderPayload),
        headers: {
            "Accept": "application/json;odata=verbose",
            "Slug": libraryUrl + "/" + folderName + "|" + folderContentTypeId
        success: function (data) {
        error: function (error) {


createFolder("LibraryName", "FolderName", "0x0120D520007ACA148760DDC646BBA59538FC81DBF9");


  1. Create SharePoint Document Set (and set metadata) using REST
  2. Is it possible to create a Document Set using REST API
  3. Creating a Document Set with the SharePoint 2013 REST API
  • I have seen the code above a lot times, why do I still have to use the _vti_bin? that's old and probably outdated. Commented Oct 6, 2022 at 20:29
  • Did you try it? Is it working for you? Commented Oct 7, 2022 at 12:02
  • If you don't want to use above API, you can try creating a folder and then update it's content type as given at: sharepoint.stackexchange.com/questions/251690/… Commented Oct 7, 2022 at 12:02
  • I am doing just that, but the problem is that the folder icon does not change. It still looks like a folder, rather than a document set. I tried to use ProgId:"SharePoint...." but did not wokr Commented Oct 7, 2022 at 13:53
  • "ProgID": "Sharepoint.DocumentSet" Commented Oct 7, 2022 at 13:54

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.