How to Create a Folder in a SharePoint List using REST API in SharePoint 2013/2016/Office 365?

Hello SharePointers,

Below are the piece of REST API code to create a folder in a SharePoint list using REST API in  SharePoint 2013/2016/Office 365?

<script type=”text/javascript”>
function getFormDigest() {
return $.ajax({
url: _spPageContextInfo.webAbsoluteUrl + “/_api/contextinfo”,
method: “POST”,
headers: { “Accept”: “application/json; odata=verbose” }

function PreSaveItem() {
var folderName=$(“input[title=’Title Required Field’]”).val(); //get new list item title
createfolder(folderName).done(function (data) {
console.log(‘Folder creatted succesfully’);
}).fail(function (error) {
return true;
function createfolder(folderName){
var documentLibraryName = “EmployeeFolder”;
var requestUri = _spPageContextInfo.webAbsoluteUrl + “/_api/web/folders”;
return getFormDigest().then(function (data) {
return $.ajax({
url: requestUri,
type: “POST”,
contentType: “application/json;odata=verbose”,
data:JSON.stringify({‘__metadata’: { ‘type’: ‘SP.Folder’ }, ‘ServerRelativeUrl’: documentLibraryName+’/’+folderName}),
headers: {

Happy SharePointing 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *