Skip to content

Instantly share code, notes, and snippets.

@vaderj
Last active June 30, 2023 14:43
Show Gist options
  • Save vaderj/f82bca9212f7418def49e56f396a1d72 to your computer and use it in GitHub Desktop.
Save vaderj/f82bca9212f7418def49e56f396a1d72 to your computer and use it in GitHub Desktop.
SP REST: Create new folder in SP Library #Javascript #REST #SharePoint
function createFolder(libraryName,newFolderName)
{
var folder = jQuery.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Folders/add('" + libraryName + "/" + newFolderName + "')",
type: 'POST',
contentType: 'application/json;odata=verbose',
headers: {
'Accept': 'application/json;odata=verbose',
'content-type':'application/json;odata=verbose',
'X-RequestDigest': $("#__REQUESTDIGEST").val()
}
});
folder.done(function(listData, textStatus, jqXHR)
{
console.dir(listData) ;
console.dir(textStatus) ;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment