1

Trying to create New Folder using the below javascript methods. URL: http://hostname.com/project/Portal Inside this URL and the in the 'ParentList' am trying to create new Folder by name 'Order 2015' inside a parent folder 'Folder1'.

Please refer the code below,

 function createFolder1(webUrl, listName, folderOptions) {
            var folderPayload = folderOptions;
            debugger
            folderPayload['Title'] = folderOptions.Url.split('/').pop();
            folderPayload['Path'] = folderOptions.Url.split('/').slice(0, -1).join('/');

            //Create Folder resource
            return $.ajax({
                url: webUrl + "/_vti_bin/listdata.svc/" + listName,
                type: "POST",
                contentType: "application/json;odata=verbose",
                data: JSON.stringify(folderPayload),
                headers: {
                    "Accept": "application/json;odata=verbose",
                    "Slug": folderOptions.Url + "|" + folderOptions.ContentTypeId
                }
            });
        }
        function createDocumentSet(webUrl, listName, docSetOptions) {
            docSetOptions.ContentTypeId = '0x0120D520';
            return createFolder1(webUrl, listName, docSetOptions);
        }


var webUrl = "http://hostname.com/project/Portal";
                var listName = 'ParentList';
                var docSetOptions = {
                    'Url': '/Folder1/Orders2015'
                };
                createDocumentSet(webUrl, listName, docSetOptions)
                .then(function (data) {
                    var itemProperties = {
                        'Description': 'Orders 2015',
                        'StartDate': '2015-06-23T07:00:00Z'
                    };
                    return updateFolderProperties(data.d, itemProperties)
                })
                .done(function () {                    
                    console.log('Document Set has been created succesfully');
                })
                .fail(function (error) {                    
                    console.log(JSON.stringify(error));
                });

This is throwing the bad request error. I am not able to figure why is this issue. Can someone please let me know the right way to achieve it. Thanks in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.