I was successfully able to create a folder in SharePoint 2013 document library using REST API in C# with below code:

<sharepoint site URL>/_api/Web/Folders/add('/DocLibName/FolderName')

I also added custom metadata columns Code, Department, Location but I was not able to add values on folder level. However, when I upload a file using REST API, the metadatas are successfully updated.

How can I add metadatas at folder level?

  • 1
    check this link Commented Jan 23, 2018 at 11:49
  • this is for renaming folder. I tried sending metadata(custom columns) but getting BAD request error. Commented Jan 23, 2018 at 12:59
  • The code for renaming the folder is the same as setting values for custom columns. If you're getting an error, you should indicate what the error details are (it should be more than "bad request").
    – wjervis
    Commented Jan 24, 2018 at 13:38

3 Answers 3


Finally got it to work using REST API. But it involves additional REST call.

Below is the code to Create a folder, from that code we will call the get Folder method to get the folder's ID:

function CreateFolder(){

            "url" : _spPageContextInfo.siteAbsoluteUrl + "/_api/Web/Folders/add('/sites/testsite/Shared Documents/newfolderRest16')",
            "type" : "POST",
            "headers" : { 
                    "accept" : "application/json; odata=verbose", 
                    "content-type" : "application/json; odata=verbose",
                    "X-RequestDigest" : $("#__REQUESTDIGEST").val()
            success: function(data){
            error: function(data){


Now, getFolder method will get the folder's ID which we will then pass to the UpdateFolder method to update the folder:

function GetFolder(data){
    var url = _spPageContextInfo.siteAbsoluteUrl + "/_api/web/getfolderbyserverrelativeurl('/sites/testsite/Shared Documents/newfolderRest16')?$expand=ListItemAllFields";


function UpdateFolder(id){  
    $.ajax ({  
        url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists/getbytitle('Documents')/items("+ id +")",
        type: "POST",  
        data: JSON.stringify({  
                type: "SP.Data.Shared_x0020_DocumentsItem"  
            "Department": "HR",
            "Location": "India"
            "Accept": "application/json;odata=verbose",  
            "Content-Type": "application/json;odata=verbose",  
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),  
            "IF-MATCH": "*",  
            "X-HTTP-Method": "MERGE"  
        success: function(data, status, xhr)  
        error: function(xhr, status, error)  

here, in the update folder method, please ensure that you are using the correct ListItemEntityTypeFullName or else it will throw bad request error.

To get the correct ListItemEntityTypeFullName, make a REST call to the below endpoint in the browser.:



Get folder using item ID:[To every folder an id is assigned] and then update item properties.

        var insertItems = [[]];
        var ItemId='1'      
        insertItems[0] = ["Department","DeptA"];
            var clientContext = SP.ClientContext.get_current();
            var oList = clientContext.get_web().get_lists().getByTitle('listname');
            var item;
            if (ItemId!='')
                item = oList.getItemById(ItemId);
            for (var i = 0; i < insertItems.length; i++) 
                if (insertItems[i][1] != undefined && insertItems[i][1] != null)
                                item.set_item(insertItems[i][0], insertItems[i][1]);

            clientContext.executeQueryAsync(function () {
                console.log('item updated');
            }, function (sender, args) {
                console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
        catch (e) {
            console.log('Request failed. ' + e.message);
  • could you please describe little more code as I am new in sharepoint Commented Jan 24, 2018 at 11:37
  • updated the original post. Please check. I have tried it at my end and its working as expected.
    – Deepmala
    Commented Jan 24, 2018 at 11:57
  • as I mentioned, I am using REST api, I cant use CSOM Commented Jan 24, 2018 at 13:11

To my knowledge Metadata for Folders is not supported in SharePoint, whether accessed via the API or UI. It's generally recommended to use separate libraries instead of folders.

  • using UI we can edit metadata by clicking 'QuickEdit' from ribbon menu Commented Jan 23, 2018 at 11:30
  • Apologies. It seems this functionality is available through the UI
    – J. Doe
    Commented Jan 23, 2018 at 11:42
  • Folder property also added through JSOM Commented May 12, 2018 at 10:38
  • do not provide missinformation. Commented Sep 16, 2020 at 16:34

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.