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?

8
  • is the option to turn on folders turned on in the advanced settings?
    – Mike
    Commented May 23, 2017 at 18:02
  • yes it is turned on
    – KumarV
    Commented May 23, 2017 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
    Commented May 23, 2017 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
    Commented May 23, 2017 at 18:09
  • Look at this: sharepoint.stackexchange.com/questions/110183/…
    – Mike
    Commented May 23, 2017 at 18:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.