0

Below code goes to success for creating folder in sharepoint list, but when I see it in list, its not created.

var url_web = _spPageContextInfo.webAbsoluteUrl;
var docLibrary = "Location_Ref";
var folderUrl =  docLibrary + "/" + "Doc-Location3";
var folderPayload = { '__metadata': { 'type': 'SP.Folder' }, 'ServerRelativeUrl': "folderPayload "}; 

  $.ajax({
        url: url_web + "/_api/web/folders",
        type: "POST",
        contentType: "application/json;odata=verbose",
        data: JSON.stringify(folderPayload),
        headers: {
            "Accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val()
        },
success: function(){
alert("success");
},
error: function(){
alert("error");
}
    });

what to do now?

  • is the option to turn on folders turned on in the advanced settings? – Mike May 23 '17 at 18:02
  • yes it is turned on – KumarV May 23 '17 at 18:05
  • Are you sure this line is correct? var folderPayload = { '__metadata': { 'type': 'SP.Folder' }, 'ServerRelativeUrl': "folderPayload "}; folderPayload isn't a server relative url no matter how you slice it, also needs a beginning slash / – Mike May 23 '17 at 18:07
  • So, what should I do then, what should I try instead of it. I have tried with giving the actual path also – KumarV May 23 '17 at 18:09
  • Look at this: sharepoint.stackexchange.com/questions/110183/… – Mike May 23 '17 at 18:09

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.