I'm using the function below to create a folder and I'm trying to make it also create a subfolder within the newly created folder.
CreateFoldersbyparent("abc","")
CreateFoldersbyparent("abc","\test")
function CreateFoldersbyparent(name,parent,callback){
var documentLibraryName = "Delte dokumenter";
var fileCollectionEndpoint = "https://gbas.sharepoint.com/Test/_api/web/getfolderbyserverrelativeurl('" + documentLibraryName + "')/folders/add(url=\'" + name + "\\" + parent + "\')";
$.ajax({
url: fileCollectionEndpoint,
type: "POST",
async: false,
headers: {
"X-RequestDigest": window.top.$("#__REQUESTDIGEST").val(),
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
},
success: function (data) {
console.log("done")
},
error: function (jqXHR, textStatus, errorThrown) {
//handle error...
console.log(jqXHR);
}
});
}
Problem is that it created 2 folders in the main root folder of "Delte dokumenter"(Shared documents in English)
What I desire:
-Delte dokumenter
-abc
-test
What it does:
-Delte dokumenter
-abc
-abctest
What am I doing wrong?